# 安装openssl apt install openssl -y #生成ssl证书 #生成ssl秘钥 openssl genrsa -des3 -out ssl.key 2048 // 返回 Generating RSA private key, 1024 bit long modulus (2 primes) ....+++++ ......+++++ e is 65537 (0x010001) Enter pass phrase for ssl.key: # 输入密码 Verifying - Enter pass phrase for ssl.key: # 再次输入密码 root@zznn:/opt/bitwarden# ls bw-data docker-compose.yml ssl.key # 配置无密码的秘钥,也可不配置,不配置的话reload nginx会提示输入密码 openssl rsa -in ssl.key -out ssl_nopass.key // 返回 Enter pass phrase for ssl.key: # 输入上面的密码 writing RSA key # 此时生成两个文件"ssl.key ssl_nopass.key" root@zznn:/opt/bitwarden# ls ssl.key ssl_nopass.key # 生成公钥证书 openssl req -new -key ssl_nopass.key -out ssl.csr // 返回 Cant load /root/.rnd into RNG 140349062406592:error:2406F079:random number generator:RAND_load_file:Cannot open file:../crypto/rand/randfile.c:88:Filename=/root/.rnd You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]: State or Province Name (full name) [Some-State]: Locality Name (eg, city) []: Organization Name (eg, company) [Internet Widgits Pty Ltd]: Organizational Unit Name (eg, section) []: Common Name (e.g. server FQDN or YOUR name) []:0.0.0.0 # 此处填服务器地址或0.0.0.0建议填0.0.0.0其他均回车不填 Email Address []:
Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: # 此处生成ssl.csr root@zznn:/opt/bitwarden# ls ssl.csr ssl.key ssl_nopass.key # 自签名CA证书,时间可以设置久一点 root@zznn:/opt/bitwarden# openssl x509 -req -days 365 -in ssl.csr -signkey ssl_nopass.key -out ssl.crt Signature ok subject=C = AU, ST = Some-State, O = Internet Widgits Pty Ltd, CN = 0.0.0.0 Getting Private key # 此时生成ssl.crt root@zznn:/opt/bitwarden# ls bw-data docker-compose.yml ssl.crt ssl.csr ssl.key ssl_nopass.key