【问题标题】:Invalid self-signed certificate自签名证书无效
【发布时间】:2017-10-14 10:29:24
【问题描述】:

我正在尝试创建自签名证书,但未能成功。我想要实现的是在我的手机上使用 webworker 测试网页,为此我确实需要 https。但目前我正在尝试在我的电脑上本地运行它。

我在 Windows 上使用 openssl(我使用来自 here 的 v1.1.0 精简版)。

我正在我的机器上安装 CA 证书,并且我正在使用提供证书和密钥的浏览器同步 https 选项来提供页面。

我得到的错误是 NET::ERR_CERT_INVALID。什么可能是无效部分?

我正在运行的命令:

openssl genrsa -des3 -out CA.key 2048
openssl req -x509 -new -nodes -key CA.key -sha256 -days 182 -out CA.pem -config ca.cfg
openssl x509 -outform der -in CA.pem -out CA.crt
openssl genrsa -out dev.key 2048
openssl req -new -key dev.key -out dev.csr -config dev.cfg
openssl x509 -req -in dev.csr -CA CA.pem -CAkey CA.key -CAcreateserial -out dev.crt -days 1825 -sha256 -extfile dev.ext
openssl pkcs12 -export -in dev.crt -inkey dev.key -out dev.p12

CA.cfg:

[ req ]

default_bits        = 2048
default_keyfile     = server-key.pem
distinguished_name  = subject
req_extensions      = req_ext
x509_extensions     = x509_ext
string_mask         = utf8only

[ subject ]

countryName                 = Country Name (2 letter code)
countryName_default         = PL

stateOrProvinceName         = State or Province Name (full name)
stateOrProvinceName_default = PL

localityName                = Locality Name (eg, city)
localityName_default        = PL

organizationName            = Organization Name (eg, company)
organizationName_default    = Example Organization

commonName                  = Common Name (e.g. server FQDN or YOUR name)
commonName_default          = Example Division

emailAddress                = Email Address
emailAddress_default        = test@example.com

[ x509_ext ]

subjectKeyIdentifier   = hash
authorityKeyIdentifier = keyid,issuer

keyUsage               = digitalSignature, keyEncipherment
subjectAltName         = @alternate_names

[ req_ext ]

subjectKeyIdentifier = hash

keyUsage             = digitalSignature, keyEncipherment
subjectAltName       = @alternate_names

[ alternate_names ]

DNS.1       = 192.168.0.17

dev.cfg

[ req ]

default_bits        = 2048
default_keyfile     = server-key.pem
distinguished_name  = subject
req_extensions      = req_ext
x509_extensions     = x509_ext
string_mask         = utf8only

[ subject ]

countryName                 = Country Name (2 letter code)
countryName_default         = PL

stateOrProvinceName         = State or Province Name (full name)
stateOrProvinceName_default = PL

localityName                = Locality Name (eg, city)
localityName_default        = PL

organizationName            = Organization Name (eg, company)
organizationName_default    = Example Organization

commonName                  = Common Name (e.g. server FQDN or YOUR name)
commonName_default          = Example Division

emailAddress                = Email Address
emailAddress_default        = test@example.com

[ x509_ext ]

subjectKeyIdentifier   = hash
authorityKeyIdentifier = keyid,issuer

keyUsage               = digitalSignature, keyEncipherment
subjectAltName         = @alternate_names

[ req_ext ]

subjectKeyIdentifier = hash

keyUsage             = digitalSignature, keyEncipherment
subjectAltName       = @alternate_names

[ alternate_names ]

DNS.1       = 192.168.0.17

dev.ext:

authorityKeyIdentifier=keyid,issuer
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names

[alt_names]
DNS.1 = 192.168.0.17

【问题讨论】:

  • 您在桌面或移动设备上遇到错误?
  • DNS.1 = 192.168.0.17 - IP 地址不是主机名。请改用IP.1。而且我也没有看到您使用有用的 CN。除此之外,不清楚您打算如何使用证书,即访问服务器时使用的 URL 是什么?
  • 我已更改为 IP.1,谢谢。可悲的是,我仍然收到“无效”错误。通过192.168.0.17:3000 访问页面时,我在桌面上收到此错误。

标签: javascript ssl https certificate browser-sync


【解决方案1】:

看来我已经失去了快速发布这个问题的希望。 我找到了this 解决方案。

同时提供 dns (localhost) 和 ip(例如 192.168.0.17)适用于 Windows 机器。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-28
    • 1970-01-01
    • 2019-08-04
    • 2012-07-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多