You can do that in one command:
(您可以通过以下命令执行此操作:)
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365
You can also add -nodes
(short for no DES
) if you don't want to protect your private key with a passphrase.
(如果您不想使用密码来保护私钥,也可以添加-nodes
( no DES
缩写)。)
Otherwise it will prompt you for "at least a 4 character" password. (否则,它将提示您输入“至少4个字符”的密码。)
The days
parameter (365) you can replace with any number to affect the expiration date.
(您可以用任何数字替换days
参数(365)以影响到期日期。)
It will then prompt you for things like "Country Name", but you can just hit Enter and accept the defaults. (然后,它将提示您输入“国家名称”之类的内容,但是您只需按Enter并接受默认值即可。)
Add -subj '/CN=localhost'
to suppress questions about the contents of the certificate (replace localhost
with your desired domain).
(添加-subj '/CN=localhost'
以取消有关证书内容的问题(将localhost
替换为所需的域)。)
Self-signed certificates are not validated with any third party unless you import them to the browsers previously.
(除非您以前将自签名证书导入浏览器,否则它们不会与任何第三方进行验证。)
If you need more security, you should use a certificate signed by a certificate authority (CA). (如果需要更高的安全性,则应使用由证书颁发机构 (CA)签名的证书 。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…