pem证书转p12和p12证书转cert、key

一、p12证书转cert

openssl pkcs12 -in cert.p12 -nokeys -out cert.crt

二、p12证书转key

openssl pkcs12 -in cert.p12 -nocerts -nodes -out cert.key

三、pem文件转p12

openssl pkcs12 -export -in cert.pem -out cert.p12 -inkey keycert.pem

四、验证cert和key是否匹配

#方法一:
(openssl x509 -noout -modulus -in cert.crt | openssl md5; openssl rsa -noout -modulus -in cert.key | openssl md5) | uniq
#方法二:
diff -eq <(openssl x509 -pubkey -noout -in cert.crt) <(openssl rsa -pubout -in cert.key)

你可能感兴趣的:(linux,linux,服务器,运维)