OpenSSL是一个强大的开源工具,用于实现SSL和TLS协议。它可以在命令行中使用,也可以作为库集成到其他应用程序中。以下是一些常用的OpenSSL命令行工具使用技巧:
openssl genpkey -algorithm RSA -out private_key.pem -aes256
这将生成一个2048位的RSA私钥,并使用AES-256加密。
openssl req -new -key private_key.pem -out certificate_signing_request.pem
在生成CSR时,您需要提供一些信息,如国家、组织名称等。
openssl req -x509 -new -nodes -key private_key.pem -sha256 -days 365 -out self_signed_certificate.pem
这将生成一个自签名的X.509证书,有效期为365天。
openssl x509 -in certificate.pem -outform DER -out certificate.der
openssl x509 -in certificate.der -inform DER -outform PEM -out certificate.pem
openssl x509 -in certificate.pem -text -noout
openssl verify -CAfile ca_certificate.pem certificate.pem
openssl dhparam -out dhparams.pem 2048
openssl genpkey -paramfile dhparams.pem -out dh_key.pem
openssl rsautl -encrypt -in plaintext.txt -out encrypted.bin -pubin -inkey public_key.pem
openssl rsautl -decrypt -in encrypted.bin -out decrypted.txt -inkey private_key.pem
openssl enc -aes-256-cbc -salt -in plaintext.txt -out encrypted.bin -pass pass:your_password
openssl enc -aes-256-cbc -d -in encrypted.bin -out decrypted.txt -pass pass:your_password
这些只是OpenSSL命令行工具的一部分功能。要了解更多关于OpenSSL的信息,请查阅官方文档或使用openssl help命令查看可用命令和选项。