How can I create a .p12 or .pfx file without a private key?

情到浓时终转凉″ 提交于 2019-11-27 11:14:19

问题


I'm trying to create a .p12 file that does not contain a valid identity (public key / private key pair) in order to test my app's certificate import functionality. Is it possible to do this with the openssl tool?

I've tried

openssl pkcs12 -in client-certonly.pem -export -out client-certonly.p12

but I get an error:

unable to load private key
471:error:0906D06C:PEM routines:PEM_read_bio:no start line:/SourceCache/OpenSSL098/OpenSSL098-50/src/crypto/pem/pem_lib.c:648:Expecting: ANY PRIVATE KEY

If it isn't possible to do this with openssl, is there another tool I can use?


回答1:


There is a very handy GUI tool written in java called portecle which you can use for creation of an empty PKCS#12 keystore and also for an import of the certificate without the private key into the PKCS#12 keystore - this functionality is available under "Import trusted certificate (Ctrl-T)" button.

However if you insist on using OpenSSL you can use this command:

openssl pkcs12 -export -nokeys -in certificate.cer -out pkcs12.pfx


来源:https://stackoverflow.com/questions/23935820/how-can-i-create-a-p12-or-pfx-file-without-a-private-key

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!