ale*_*exW 11 https openssl ssl-certificate certificate-authority self-signed-certificate
我正在创建 https 服务器端,用于练习 Instagram 的 OAuth,这需要 https。
我通过从以下链接运行脚本来使用 ssl 生成证书:https://gist.github.com/bjanderson/075fadfccdd12623ab935e57eff58eb4
脚本运行得很好,我收到了所有预期的文件。我已在受信任的根证书颁发机构下将 ca.crt 导入到我的 chrome 中,但 chrome 仍然不信任它。导入位置是否合适,因为 chrome 有许多不同的部分可以导入 ca.crt。
我收到以下错误:
证书 - 缺少使用者备用名称 此站点的证书不包含包含域名或 IP 地址的使用者备用名称扩展。
证书 - 丢失 该站点缺少有效的、受信任的证书 (net::ERR_CERT_AUTHORITY_INVALID)。
如何解决这两个问题并让我的 Chrome 信任我的自签名证书?
正如它所说,主题备用名称是列出主题的备用名称的地方。这是对“主题”字段的一项改进,因为它允许多个主题名称,而“主题”仅允许一个。现代浏览器仅查看主题备用名称扩展并忽略主题字段。
要制作适用于现代浏览器的自签名证书,请创建一个类似于以下内容的 OpenSSL 配置文件并将其另存为openssl.cnf
:
######################################################
# OpenSSL config to generate a self-signed certificate
#
# Create certificate with:
# openssl req -x509 -new -nodes -days 720 -keyout selfsigned.key -out selfsigned.pem -config openssl.cnf
#
# Remove the -nodes option if you want to secure your private key with a passphrase
#
######################################################
################ Req Section ################
# This is used by the `openssl req` command
# to create a certificate request and by the
# `openssl req -x509` command to create a
# self-signed certificate.
[ req ]
# The size of the keys in bits:
default_bits = 2048
# The message digest for self-signing the certificate
# sha1 or sha256 for best compatability, although most
# OpenSSL digest algorithm can be used.
# md4,md5,mdc2,rmd160,sha1,sha256
default_md = sha256
# Don't prompt for the DN, use configured values instead
# This saves having to type in your DN each time.
prompt = no
string_mask = default
distinguished_name = req_dn
# Extensions added while singing with the `openssl req -x509` command
x509_extensions = x509_ext
[ req_dn ]
countryName = GB
stateOrProvinceName = Somewhere
organizationName = Example
commonName = Example Web Service
[ x509_ext ]
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always
# No basicConstraints extension is equal to CA:False
# basicConstraints = critical, CA:False
keyUsage = critical, digitalSignature, keyEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1 = www.example.com
DNS.2 = www.example.org
Run Code Online (Sandbox Code Playgroud)
跑步:
openssl req -x509 -new -nodes -days 720 -keyout selfsigned.key -out selfsigned.crt -config openssl.cnf
Run Code Online (Sandbox Code Playgroud)
添加selfsigned.crt
到浏览器的信任锚存储区。
如果您现在修复您的 DNS 解析(本地 DNS 或/etc/hosts
文件),以便www.example.org
或www.example.com
指向127.0.0.1
您可以访问www.example.com
或www.example.org
没有 Chrome 抱怨。
要测试,请运行:
openssl s_server -cert selfsigned.crt -key selfsigned.key -www -accept 8443
Run Code Online (Sandbox Code Playgroud)
将您的浏览器指向https://www.example.org:8443
- 您应该会获得可用密码套件的列表和一些会话信息。您不应收到证书警告。
归档时间: |
|
查看次数: |
21673 次 |
最近记录: |