[zz]How can I generate PFX file to sign the documents?

https://bytescout.com/support/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=296&nav=0,1,14

 

.PFX file (Personal Information Exchange format) is the file containing both a public (.cer file) and a private (.pvk file) keys. You can use this file to sign your files and PDF documents (using Bytescout PDF SDK for .NET)

To generate .PFX certificate file please follow the tutorial:

 

1) Explore into c:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\ folder
2) type "cmd" to run command console
3) type the following to generate new key and press Enter: makecert.exe -sv MyKey.pvk -n "CN=MY DIGITAL KEY" MyKey.cer
4) "Create Private Key Password" dialog will appear. Enter your password for the key. NOTE: Write down the password and keep it in a safe place. Click OK to close this dialog. The "MyKey.pvk" file will be generated and saved into the same folder.
5) Now "Enter Private Key Password" dialog will appear. You should type the same password you've entered on step (4)
This will generate "MyKey.cer" file
6) Close command line console
7) Copy files: MyKey.pvk and MyKey.cer into C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\Bin\ folder
8) Type "cmd" to run command line console (in the C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\Bin\ folder)
9) Now merge MyKey.cer and MyKey.pvk into one single .pfx file (MyPFX.pfx file)
10) Type (in the command line): pvk2pfx.exe -pvk MyKey.pvk -spc MyKey.cer -pfx MyPFX.pfx
11) The "Enter Private Key Password" dialog will appear. Enter your password for the private key as you've entered on (4)
12) "MyPFX.pfx" file will be generated in the C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\Bin\ folder

NOTE: you can specify the password in the command line by using -po command line switch,
for example: pvk2pfx.exe -pvk MyKey.pvk -spc MyKey.cer -pfx MyPFX.pfx -po MyPasswordToSignPDF

Where "MyPasswordToSignPDF" is the password (different from the password for the .pvk on step (4). This password (MyPasswordToSignPDF) will be used as a last parameter for Document.AddSignature() method in Bytescout PDF SDK

For example:

If you have used the command line:  pvk2pfx.exe -pvk MyKey.pvk -spc MyKey.cer -pfx MyPFX.pfx -po MyPasswordToSignPDF

Then you should use the following code in your application: Document.AddSignature("MyPFX.pfx", "John Doe", "Approved", false, "MyPasswordToSignPDF");

posted @ 2010-07-11 11:24  bettermanlu  阅读(502)  评论(1编辑  收藏  举报