OpenSSL 命令使用教程

发布时间:2017/3/12 19:34:07 打印 字号:

获取证书 Public key

openssl rsa -in certificate.pem -out publickey.pem -outform PEM -pubout

生成自签名证书

openssl req -nodes -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 356

删除私钥(KEY)密码

openssl rsa -in private.key -out unencrypted.key -outform PEM

生成带密码的私钥

openssl genrsa -des3 -out private.key 2048

使用带密码的私钥生成CSR

openssl req -new -passin pass:密码 -passout pass:密码 -key private.key -out server.csr获取证书HASH
openssl x509 -noout -hash -in newcert.pem

PEM格式转DER

openssl x509 -outform der -in certificate.pem -out certificate.der

PEM格式转成P7B

openssl crl2pkcs7 -nocrl -certfile certificate.cer -out certificate.p7b -certfile CACert.cer

PEM格式转成PFX
openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile CACert.crt

DER格式转PEM

openssl x509 -inform der -in certificate.cer -out certificate.pem

P7B格式转成PEM

openssl pkcs7 -print_certs -in certificate.p7b -out certificate.cer

P7B格式转成PFX

openssl pkcs7 -print_certs -in certificate.p7b -out certificate.cer
openssl pkcs12 -export -in certificate.cer -inkey privateKey.key -out certificate.pfx -certfile CACert.cer

PFX格式转成PEM

openssl pkcs12 -in certificate.pfx -out certificate.cer -nodes

证书解码

openssl x509 -in certificate.crt -text -noout

PFX导出私钥

openssl pkcs12 -in domain.com.pfx -nocerts -out privateKey.pem

PRIVATE KEY 转成 RSA PRIVATE KEY

openssl rsa -in domain.key -out domain-rsa.key