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nQwDAYDVR0TAQH/BAIwADCCAQYGCisGAQQB1nkC
BAIEgfcEgfQA8gB3AKS5CZC0GFgUh7sTosxncAo8NZgE+RvfuON3zQ7IDdwQAAAB
ZkIJ+SMAAAQDAEgwRgIhAPCadxv47cB4QOOvN9s/R23EepEbSI4/MuAdf5vKeU79
AiEA2gZ3O8nzuUVanRW9fg6mgfsL08Nn/ZGm73O/F3IGX2UAdwCHdb/nWXz4jEOZ
X73zbv9WjUdWNv9KtWDBtOr/XqCDDwAAAWZCCfoGAAAEAwBIMEYCIQDQjfmVBq+/
y2gBK/eE9x6jz9hTZ5tIfhkStS85fMAxegIhAMAuNkyuO4t06EiEgMWialJZuAnk
Qw29GceIBG8r1Ap3MA0GCSqGSIb3DQEBCwUAA4IBAQAAk873/+2QswKfJSQn+iZe
Zc8uiGg99pmd008E2cmGErqNzPclK9INbPjwxl9zIgTcXpF/UtBVVS1Z7Xo83qfs
GMPdMzYt3F+hQpQYLhlGF+5Jf2x6Zb1zjT/aM3GMdGi+6OPV+YHl/wgUe45N6kRu
DZnVL167+W3l2nD+mShO/7xqwHiZuz0GHyBHRp5i43blH0vg67sJ8guN81papupY
2v78FcvR8j0ELfgyehtWpjF3vzKSq/rY2sMXTYzSPqMeksseHNhSMYU6Ww9h9pyM
aVnw9vahqf7nKHHcC2VRTUgkQfn9yDmmBOo0nQ8Xgfpd65/PaxVfBnuKfEkXBfpM
-----END CERTIFICATE-----
例如,我将以上内容作为test.pem文件,而我尝试过:
openssl rsa -in test.pem -out test.key
openssl pkey -in test.pem -out test.key
我遇到了错误:
unable to load Private Key
4611995244:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:697:Expecting: ANY PRIVATE KEY
unable to load key
4771477100:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:697:Expecting: ANY PRIVATE KEY
答案 0 :(得分:0)
如果要提取证书的公钥,则要查找的命令是(在 OpenSSL 1.1.0或更高版本中):
openssl x509 -pubkey -noout -out key.pem -in cert.pem
x509
:x509证书操作命令。-pubkey
:告诉命令在输出中写入证书的公钥。-noout
:告诉命令不要在输出中打印证书。-out <file>
:定义用于将输出打印到的文件。-in <file>
:定义要解释的证书。如果您使用的是 OpenSSL 1.0.2 ,请使用:
openssl x509 -pubkey -noout -in cert.pem > key.pem