我在机器上设置了一个https服务器,并在该服务器上安装了服务sorker。当我在浏览器中添加证书后通过桌面chrome浏览器打开网站时,它可以正常打开。但是当我尝试在android设备中打开它时显示以下错误。
提取脚本时发生SSL证书错误。
https://www.aaa.com/swt1.js无法加载资源:net :: ERR_INSECURE_RESPONS E
安装Service Worker时出错:DOMException:无法注册ServiceWorker:提取脚本时发生SSL证书错误。
其中swt1.js是我的服务工作者文件。
问题是什么..这是证书的安装或与服务人员有关的问题。
问题出在我的自签名openssl证书中。要在android上使用自签名证书,该证书应具有“基本约束CA = true ”。在openssl中,默认值为CA = false。因此我们需要将该值更改为true。下面的文件是我的openssl.conf。
HOME = .
RANDFILE = $ENV::HOME/.rnd
####################################################################
[ ca ]
default_ca = CA_default # The default ca section
[ CA_default ]
default_days = 1000 # how long to certify for
default_crl_days= 30 # how long before next CRL
default_md = sha256 # use public key default MD
preserve = no # keep passed DN ordering
x509_extensions = ca_extensions # The extensions to add to the cert
email_in_dn = no # Don't concat the email in the DN
copy_extensions = copy # Required to copy SANs from CSR to cert
####################################################################
[ req ]
default_bits = 4096
default_keyfile = cakey.pem
distinguished_name = ca_distinguished_name
x509_extensions = ca_extensions
string_mask = utf8only
####################################################################
[ ca_distinguished_name ]
countryName = countryName
countryName_default = countryName_default
stateOrProvinceName = stateOrProvinceName
stateOrProvinceName_default = stateOrProvinceName_default
localityName = localityName
localityName_default = localityName_default
organizationName = organizationName
organizationName_default = Test CA, Limited
organizationalUnitName = organizationalUnitName
organizationalUnitName_default = Server Research Department
commonName = commonName
commonName_default = commonName
emailAddress = emailAddress
emailAddress_default = [email protected]
####################################################################
[ ca_extensions ]
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always, issuer
basicConstraints = critical, CA:true
keyUsage = keyCertSign, cRLSign
如果找不到您的文件,请使用上述内容制作一个名为openssl.conf的文件。并运行此命令
openssl req -x509 -config openssl.cnf -newkey rsa:4096 -sha256 -nodes -out server.pem -outform PEM
并在Android上安装证书,我使用了CAdroid应用程序。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句