“ BEGIN RSA PRIVATE KEY”和“ BEGIN PRIVATE KEY”之间的区别

嗨,我正在编写一个程序,该程序从.pem文件导入私钥并创建私钥对象以供以后使用。.我所面临的问题是某些pem文件头以


-----BEGIN PRIVATE KEY-----

而其他人开始


-----BEGIN RSA PRIVATE KEY-----

通过搜索,我知道第一个是PKCS#8格式化的,但是我不知道另一个属于什么格式。


茅侃侃
浏览 3019回答 3
3回答

慕哥9229398

看一看<openssl/pem.h>。它给出了可能的BEGIN标记。复制以上链接中的内容以供快速参考:#define PEM_STRING_X509_OLD "X509 CERTIFICATE"#define PEM_STRING_X509&nbsp; &nbsp; &nbsp;"CERTIFICATE"#define PEM_STRING_X509_PAIR&nbsp; &nbsp; "CERTIFICATE PAIR"#define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE"#define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST"#define PEM_STRING_X509_REQ "CERTIFICATE REQUEST"#define PEM_STRING_X509_CRL "X509 CRL"#define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY"#define PEM_STRING_PUBLIC&nbsp; &nbsp;"PUBLIC KEY"#define PEM_STRING_RSA&nbsp; &nbsp; &nbsp; "RSA PRIVATE KEY"#define PEM_STRING_RSA_PUBLIC&nbsp; &nbsp;"RSA PUBLIC KEY"#define PEM_STRING_DSA&nbsp; &nbsp; &nbsp; "DSA PRIVATE KEY"#define PEM_STRING_DSA_PUBLIC&nbsp; &nbsp;"DSA PUBLIC KEY"#define PEM_STRING_PKCS7&nbsp; &nbsp; "PKCS7"#define PEM_STRING_PKCS7_SIGNED "PKCS #7 SIGNED DATA"#define PEM_STRING_PKCS8&nbsp; &nbsp; "ENCRYPTED PRIVATE KEY"#define PEM_STRING_PKCS8INF "PRIVATE KEY"#define PEM_STRING_DHPARAMS "DH PARAMETERS"#define PEM_STRING_DHXPARAMS&nbsp; &nbsp; "X9.42 DH PARAMETERS"#define PEM_STRING_SSL_SESSION&nbsp; "SSL SESSION PARAMETERS"#define PEM_STRING_DSAPARAMS&nbsp; &nbsp; "DSA PARAMETERS"#define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY"#define PEM_STRING_ECPARAMETERS "EC PARAMETERS"#define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY"#define PEM_STRING_PARAMETERS&nbsp; &nbsp;"PARAMETERS"#define PEM_STRING_CMS&nbsp; &nbsp; &nbsp; "CMS"

偶然的你

要生成PKCS#1密钥,openssl genrsa可以使用该命令。使用openssl req同时生成私钥和CRT将结束与一个PKCS#8键。在genpkey手动状态The use of the genpkey program is encouraged over the algorithm specific utilities because additional algorithm options and ENGINE provided algorithms can be used.。但是某些软件(mysql)只能使用PKCS#1密钥。从转换PKCS#8到PKCS#1是可以做到的openssl rsa -in key.pem -out key.pem。可以使用进行其他转换openssl pkey -in key.pem -out key.pem。
打开App,查看更多内容
随时随地看视频慕课网APP