我有一个文件,其中包含:
-----BEGIN CERTIFICATE----- (many lines of 64 bytes) -----END CERTIFICATE-----
我使用keytool.exe -printcert -file (myfile)
它输出像这样
Certificate[1]: Owner: CN=www.mydomain.xxxxxx (bah bah bah............) (bah bah bah............) Certificate[2]: Owner: CN=Thawte SSL CA, O="Thawte, Inc.", C=US (bah bah bah............) (bah bah bah............) Certificate[3]: Owner: CN=thawte Primary Root CA, OU="(c) 2006 thawte, Inc. - For authorized use only", OU=Certification Services Division, O="thawte, Inc.", C=US (bah bah bah............) (bah bah bah............)
它包含3个证书是否正常?
它被称为证书链吗?
如果我想将该文件导入到keystore
我该怎么办?
我已经尝试了一遍又一遍的使用
keytool.exe -import -alias (myalias) -trustcacerts -file (thisfile) -keystore (mykeystore)`
但它一直告诉我
java.lang.Exception: Input not an X.509 certificate
keytool
要求以PKCS#7格式(通常是.p7b
文件扩展名)提供证书链,但是您将其作为PEM文件(相当于Apache , nginx等软件使用)。
从keytool
手册 ( -importcert
选项):
-importcert:
读取证书或证书链( 后者在PKCS#7格式的答复中提供 )…
要转换文件,你可以使用openssl
工具(如果你有它的话):
openssl crl2pkcs7 -certfile cert.pem -out cert.p7b -nocrl
其中cert.pem
是您当前的证书文件, cert.p7b
是用于导入的证书文件。