如何阅读.pfx文件? [英] How to read the .pfx file?
问题描述
我使用ASP.NET,C#和iTextSharp的5.3.0用于创建和数字签名的PDF文件。然后,我需要使用PFX文件,而签约。有人能解释一下它会包含哪些内容?
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?
编辑:
谢谢,所以它具有密钥对。
Thanks, so it is having the keypair.
我也用这个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.
推荐答案
请阅读iText的和数字签名白皮书:的 http://itextpdf.com/book/digitalsignatures
Please read the white paper on iText and digital signatures: http://itextpdf.com/book/digitalsignatures
一个PFX文件是包含私有和公共密钥对旧的类型的文件。你可以使用它,你会使用一个P12文件的方式。这是在文档中解释。注意#2旧的答案不再适用。数字签名功能已经被完全重写。
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.
如果你不知道如何在C#中创建一个密钥库:
In case you don't know how to create a KeyStore in C#:
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;
}
}
这篇关于如何阅读.pfx文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!