I am using ASP.NET, C# and iTextSharp 5.3.0 for creating and digitally signing a PDF. Then I need to use pfx file while signing. Can someone explain what it will contain?
Edit:
Thanks, so it is having the keypair.
I did used this code.
FileStream fs = new FileStream(CERT_PATH, FileMode.Open);
Pkcs12Store ks = new Pkcs12Store(fs, CERT_PASSW.ToCharArray());
string alias = null;
foreach (string al in ks.Aliases)
{
if (ks.IsKeyEntry(al) && ks.GetKey(al).Key.IsPrivate)
{
alias = al;
break;
}
}
Certificate[] x = ks.getCertificateChain(alias)
X509Certificate[] chain=new X509Certificate[x.length]
for(int k=0;k<x.length;k++)
{
chain[k]=x[k].Certificate;
}
Thanks, It is working fine now.
Please read the white paper on iText and digital signatures: http://itextpdf.com/book/digitalsignatures
A PFX file is an old type of file containing a private and public key pair. You can use it the same way you’d use a P12 file. This is explained in the documentation. Note that old answers on Stackoverflow no longer apply. The digital signature functionality has been completely rewritten.
In case you don’t know how to create a KeyStore in C#: