下列是常用的OpenSSL命令列表
作为一个开源工具,OpenSSL可用于Windows,Linux,macOS,Solaris,QNX以及大多数主要操作系统。
以C编程语言编写的核心库,OpenSSL命令可用于执行从CSR生成到转换证书格式等数百种功能。但对于只想安装SSL证书的人来说,只有少数命令是非常必要的。下面是安装SSL证书时常要用到的OpenSSL命令及其应用程序。
用于生成私钥的OpenSSL命令
openssl genrsa -out yourdomain.key 2048
OpenSSL命令检查您的私钥
openssl rsa -in privateKey.key -check
OpenSSL命令来生成CSR
如果已生成私钥:
openssl req -new -key yourdomain.key -out yourdomain.csr
一旦执行这个命令,会被要求更多的细节。输入如下信息:
如果还没有生成私钥:
该命令将一次生成CSR和私钥。
openssl req -new \
-newkey rsa:2048 -nodes -keyout yourdomain.key \
-out yourdomain.csr \
-subj “/C=US/ST=Florida/L=Saint Petersburg/O=Your Company, Inc./OU=IT/CN=”
OpenSSL命令检查CSR
openssl req -text -noout -verify -in CSR.csr
用于转换证书和密钥文件的OpenSSL命令
OpenSSL命令转换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.cert
将PEM转换为PFX
openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile CACert.crt
OpenSSL命令来转换DER文件
将DER转换为PEM
要转换证书文件:
openssl x509 -inform DER -in yourdomain.der -outform PEM -out yourdomain.crt
要转换私钥文件:
openssl rsa -inform DER -in yourdomain_key.der -outform PEM -out yourdomain.key
OpenSSL命令转换P7B文件
将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
OpenSSL命令转换PKCS#12(.pfx)文件
将PFX转换为PEM
要转换证书文件:
openssl pkcs12 -in certificate.pfx -out certificate.cer -nodes
要转换私钥文件:
openssl pkcs12 -in yourdomain.pfx -nocerts -out yourdomain.key -nodes
OpenSSL命令检查证书
openssl x509 -in certificate.crt -text -noout
用于检查PKCS#12文件(.pfx文件)的OpenSSL命令
openssl pkcs12 -info -in keyStore.p12
猜你喜欢