一.申請數字證書
1)注冊賬號,選擇代碼簽名證書

2)選擇產品年限,下訂單.等待優惠碼(最多打5折)
3)支付,可以選擇支付寶,是不是很方便.她們客服的聲音很甜奧
4)提交csr文件.生成csr也是一個很大的坑啊,Godaddy給的鏈接(https://www.godaddy.com/help/windows-generate-csr-for-code-or-driver-signing-certificate-7282?v=1)不行.http://support.godaddy.com/help/article/2698?
使用OpenSSL生成CSR,機器要選擇vs打包的機器(生成clickonce的機器)可以參考此鏈接:http://www.vbgudu.com/html/20160628/53282.html
5)提交后就等待等審核吧,第一個可能會很慢,需要你提交公司的文件啊...
如果是老用戶,或者是重新生成pfx證書,那就很快了.三個小時內應該可以.我最快10分鍾.
全部審核通過后,會讓你下載一個壓縮包
6)下載壓縮包

解壓后會有一個spc文件.

在命令行輸入mmc,
- In your Windows search feature, enter mmc, and then click it to launch the Microsoft Management Console application.
- Expand Certificates (Local Computer), Personal.
- Right-click Certificates, and then go to the following menus: All Tasks > Imprt.
- Click Next.
- Browse for the
SPCfile — to find it, you'll need to change the file type to PKCS #7 Certificates (*.spc, *.p7b). - Click Next.
- Select Place all certificates in the following store and ensure the value isPersonal.
- Click Finish.
8)有可能pfx文件選擇不上,
To create a PFX file (which you'll use with SignTool or Visual Studio), you need to combine your certificate file and your private key in MMC.
- In MMC, right-click your certificate (it will have your Common Name value displayed in the Issued To column), and then click Export.
- Click Next.
- Select Yes, export the private key.
- Under Personal Information Exchange..., select Include all certificates in the certitification path if possible.
- Enter and confirm a strong password to secure the certificate, and then click Next.
- Browse to a location to store the combined file, and then click Next.
- Click Finish.
The PFX file is now stored locally on your computer.

那你只能通過生成Base 64 encoded X.509(.Cer)文件.然后通過OpenSSL生成.pfx文件.
可參考此鏈接:http://blog.csdn.net/linda1000/article/details/8676330
使用此命令即可
openssl pkcs12 -export -in certificate.cer -inkey privateKey.key -out certificate.pfx -certfile CACert.cer
至此大功告成.生成pfx文件.
9)打開VS2015,選擇項目屬性-->簽名--->為ClickOnce清單簽名,從文件選擇,不要使用VS2013,雖然打包會成功,但是安裝會失敗,報錯
SignatureDescription could not be created for the signature algorithm supplied,解決方案,使用VS2015.

