我的计算机上有.CER文件。我想从中打印私钥和公钥并将其存储在DB中。我怎么能这样做?
到目前为止,谷歌搜索后,这是我尝试过的,我正在追踪错误。
openssl x509 -inform der -in apple_pay.cer -pubkey -noout > apple_pay.pem
openssl x509 -in apple_pay.pem -text
unable to load certificate
69889:error:0906D06C:PEM routines:PEM_read_bio:no start line:/BuildRoot/Library/Caches/com.apple.xbs/Sources/OpenSSL098/OpenSSL098-59.60.1/src/crypto/pem/pem_lib.c:648:Expecting: TRUSTED CERTIFICATE
KOPC02KW5T9F6T6:ApplePaySwag-Starter chandeln$
我还尝试了以下来自https://www.openssl.org/docs/manmaster/apps/pkey.html
的命令KOPC02KW5T9F6T6:ApplePaySwag-Starter chandeln$ openssl pkey -in apple_pay.pem -text -noout
openssl:Error: 'pkey' is an invalid command.
答案 0 :(得分:1)
执行openssl x509 -inform der -in apple_pay.cer -pubkey -noout > apple_pay.pem
后,您在apple_pay.pem
openssl x509
适用于x509证书,因此无法从apple_pay.pem
加载公钥。
无法从证书或公钥中提取私钥。 这是不对称密码的主要思想。