赞
踩
首先新建一个配置文件 ssl.conf
如下:
[ req ] default_bits = 4096 distinguished_name = req_distinguished_name req_extensions = req_ext [ req_distinguished_name ] countryName = Country Name (2 letter code) countryName_default = GB stateOrProvinceName = State or Province Name (full name) stateOrProvinceName_default = England localityName = Locality Name (eg, city) localityName_default = Brighton organizationName = Organization Name (eg, company) organizationName_default = Hallmarkdesign organizationalUnitName = Organizational Unit Name (eg, section) organizationalUnitName_default = IT commonName = Common Name (e.g. server FQDN or YOUR name) commonName_max = 64 commonName_default = localhost [ req_ext ] subjectAltName = @alt_names [alt_names] IP.1 = 192.168.1.8 DNS.1 = your-website.dev DNS.2 = another-website.dev
openssl genrsa -out private.key 4096
openssl req -new -sha256 \
-out private.csr \
-key private.key \
-config ssl.conf
这里会要求输入一系列参数,可以选择不填直接回车。
可以使用下面的命令是查看证书内容:
openssl req -text -noout -in private.csr
应该可以看到:
X509v3 Subject Alternative Name: DNS:my-project.site
and Signature Algorithm: sha256WithRSAEncryption
然后生成证书命令如下:
openssl x509 -req \
-days 3650 \
-in private.csr \
-signkey private.key \
-out private.crt \
-extensions req_ext \
-extfile ssl.conf
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。