ubuntu

OpenSSL命令Ubuntu下怎么用

小樊
43
2026-01-05 09:47:54
栏目: 云计算

在Ubuntu系统下,OpenSSL是一个非常强大的加密工具,可以用于生成证书、密钥、签名等。以下是一些常用的OpenSSL命令及其用法:

1. 生成RSA私钥

openssl genrsa -out private.key 2048

2. 生成自签名证书

openssl req -new -x509 -key private.key -out certificate.crt -days 365

3. 生成CSR

openssl req -new -key private.key -out certificate.csr

4. 查看证书信息

openssl x509 -in certificate.crt -text -noout

5. 查看私钥信息

openssl rsa -in private.key -check

6. 生成DH参数文件

openssl dhparam -out dhparam.pem 2048

7. 生成ECC密钥对

openssl ecparam -genkey -name secp384r1 -out private_ec.key
openssl ec -in private_ec.key -pubout -out public_ec.pem

8. 生成PKCS#12格式的文件

openssl pkcs12 -export -in certificate.crt -inkey private.key -out keystore.p12 -name mycert

9. 解密PKCS#12文件

openssl pkcs12 -in keystore.p12 -out certificate.crt -clcerts -nokeys
openssl pkcs12 -in keystore.p12 -out private.key -nocerts -nodes

10. 生成随机数

openssl rand -base64 32

这些命令只是OpenSSL功能的一部分,更多高级功能和选项可以通过查看openssl的手册页(man openssl)来了解。

0
看了该问题的人还看了