Debian 系统 OpenSSL 命令速查
一 安装与版本
sudo apt update && sudo apt install openssl libssl-devopenssl version二 密钥与证书管理
openssl genrsa -out rsa_key.pem 2048openssl rsa -in rsa_key.pem -pubout -out rsa_key.pubopenssl req -new -key rsa_key.pem -out request.csropenssl req -new -x509 -days 365 -key rsa_key.pem -out certificate.crtopenssl x509 -in certificate.crt -text -nooutopenssl x509 -in certificate.crt -outform DER -out certificate.deropenssl x509 -in certificate.der -inform DER -out certificate.pemopenssl verify -CAfile ca.crt certificate.crt三 对称加密与文件处理
openssl enc -aes-256-cbc -salt -in plain.txt -out encrypted.binopenssl enc -d -aes-256-cbc -in encrypted.bin -out decrypted.txtopenssl rand -base64 32openssl dgst -sha256 file.txtopenssl dgst -md5 file.txtopenssl rsautl -encrypt -inkey rsa_key.pub -pubin -in plain.txt -out encrypted.encopenssl rsautl -decrypt -inkey rsa_key.pem -in encrypted.enc -out decrypted.txt四 密钥交换与参数
openssl dhparam -out dhparams.pem 2048openssl ecparam -name secp384r1 -genkey -noout -out ecdhkey.pemopenssl pkey -in ecdhkey.pem -pubout -out ecdhpub.pem五 PKI 与服务器部署
openssl pkcs12 -export -in certificate.crt -inkey rsa_key.pem -out keystore.p12 -name mycertsudo cp certificate.crt /etc/ssl/certs/ && sudo cp rsa_key.pem /etc/ssl/private/SSLCertificateFile /etc/ssl/certs/certificate.crt
SSLCertificateKeyFile /etc/ssl/private/rsa_key.pem
sudo systemctl restart nginx