tre*_*esf 17 ssl https firefox certificate websocket
随着Firefox 54的最近升级,我的自签名localhost
SSL证书不再受到信任.
我一直在使用Firefox AutoConfigure脚本来安装此证书,该技术已经成功运行了好几年.Firefox使用自己的证书存储区,cert8.db
其中包含证书,使用Firefox首选项,高级版,证书,查看证书,权限进行验证.
这在MacOS和Windows上都是可重现的.我附上了样本证书以供参考.这与我们安装的相同.
Firefox 54有什么变化?我查看了更改日志,但找不到任何特定于它如何信任证书的内容.
编辑:链接到Firefox错误,最有可能引入此更改:firefox
#1294580
-----BEGIN CERTIFICATE-----
MIID/DCCAuSgAwIBAgIEDZj+fTANBgkqhkiG9w0BAQsFADCBmjELMAkGA1UEBhMC
VVMxCzAJBgNVBAgTAk5ZMRIwEAYDVQQHEwlDYW5hc3RvdGExGzAZBgNVBAoTElFa
IEluZHVzdHJpZXMsIExMQzEbMBkGA1UECxMSUVogSW5kdXN0cmllcywgTExDMRww
GgYJKoZIhvcNAQkBFg1zdXBwb3J0QHF6LmlvMRIwEAYDVQQDEwlsb2NhbGhvc3Qw
HhcNMTcwMjEyMDMzMjEwWhcNMzcwMjEyMDMzMjEwWjCBmjELMAkGA1UEBhMCVVMx
CzAJBgNVBAgTAk5ZMRIwEAYDVQQHEwlDYW5hc3RvdGExGzAZBgNVBAoTElFaIElu
ZHVzdHJpZXMsIExMQzEbMBkGA1UECxMSUVogSW5kdXN0cmllcywgTExDMRwwGgYJ
KoZIhvcNAQkBFg1zdXBwb3J0QHF6LmlvMRIwEAYDVQQDEwlsb2NhbGhvc3QwggEi
MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCemwdWhvytOwhsRyEo/9ck3nKP
oBvMdkaiXKbMWlYZfYyb/EsJzw/LiEqGGhflWjneQLcgq0nuTtRaA9cm/vgPtVRX
OHewJeYBI2C4avJyjdFfQYHJKxuLi3nwmZ5JwcDm04H6SADwdyQuYB4AFr32uY5D
3id0gyDV+EX9sSOPThtdBpEbaBcFmAdAGdQUCzSJyi4Yu6UkIs7OPBHp9lOvm8VQ
r6ZVnqdFEXmxgpgMS0sQwDwZnBB3hFcVmE/sYy+2gV/h+yvRUjgqwC/SoLh9f4D0
eG19E3OEmsSyFM9K2Wl4ltOE/Aq1KFm7dPw34nDKxYcVDpm6JczWycbCi4zjAgMB
AAGjSDBGMCUGA1UdEQQeMByCCWxvY2FsaG9zdIIPbG9jYWxob3N0LnF6LmlvMB0G
A1UdDgQWBBT3Qs6/qQSmunLIGKQxz3GBO+RgIzANBgkqhkiG9w0BAQsFAAOCAQEA
lVI3sWr6wTtVtc7gsV9Kk99xNOUm5W2kp/Ot5CHvUIw68Ar1WIiouWT9BbjkvFc+
QpbtqKhluTdHI1/JP44r7A8qMApyYQLhw3AS/WTzRoOBOECJk3hYgGBIxAaoqvKY
HKCOULTqkoX8pgNhYobebn/BpeoSvXW+oxT21y7ElE01eMtrLsqXKaN5FODxVzJq
7jatxCaRZCy2Ki3R0cB5ZMIVvWSDeT1TLgh5UKWdldNsTdTNhbQSdm8ayU0uj4fH
tKqwh9lKvrBJiawghmADjZjeNEQzIJfjznF/soqVZnRNZO/phDH327lDE2UcD1IN
k4BqNRJmz5lrQeYz8GcfYA==
-----END CERTIFICATE-----
Run Code Online (Sandbox Code Playgroud)
Zom*_*aya 12
受@tresf答案的启发,主要基于Brad Touesnard 的博客文章如何为本地HTTPS开发创建自己的SSL证书颁发机构,我创建了一组命令openssl
.
# Generate the root key
openssl genrsa -des3 -out myCA.key 2048
# Generate a root-certificate based on the root-key
openssl req -x509 -new -nodes -key myCA.key -sha256 -days 1825 -out myCA.pem
# Generate a new private key
openssl genrsa -out example.com.key 2048
# Generate a Certificate Signing Request (CSR) based on that private key
openssl req -new -key example.com.key -out example.com.csr
# Create a configuration-file
echo \
"authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = example.com
"> example.com.conf
# Create the certificate for the webserver to serve
openssl x509 -req -in example.com.csr -CA myCA.pem -CAkey myCA.key -CAcreateserial \
-out example.com.crt -days 1825 -sha256 -extfile example.com.conf
Run Code Online (Sandbox Code Playgroud)
添加myCa.pem
到您的浏览器/钥匙串以信任由新根证书签名的证书
添加example.com.crt
和example.com.key
配置您的网络服务器以对您的域名进行签名请求
tre*_*esf 10
要模仿Firefox 54强制要求的CA链,需要满足以下条件:
为了说明如何使用Java完成此操作,keytool
包括创建私钥库的步骤:
# Create a Root-CA private keystore capable of issuing SSL certificates
keytool -genkeypair -noprompt -alias my-ca -keyalg RSA -keysize 2048 -dname CN=localhost -validity 3650 -keystore .\my-ca.jks -storepass pass77 -keypass pass77 -ext ku:critical=cRLSign,keyCertSign -ext bc:critical=ca:true,pathlen:1
# Export the Root-CA certificate, to be used in the final SSL chain
keytool -exportcert -alias my-ca -keystore .\my-ca.jks -storepass pass77 -keypass pass77 -file .\my-ca.crt -rfc -ext ku:critical=cRLSign,keyCertSign -ext bc:critical=ca:true,pathlen:1
# Create a container SSL private keystore (external localhost.foo.bar dns entry optional:IE11 domain intranet policy)
keytool -genkeypair -noprompt -alias my-ssl -keyalg RSA -keysize 2048 -dname CN=localhost -validity 3650 -keystore .\my-ssl.jks -storepass pass77 -keypass pass77 -ext ku:critical=digitalSignature,keyEncipherment -ext eku=serverAuth,clientAuth -ext san=dns:localhost,dns:localhost.foo.bar -ext bc:critical=ca:false
# Create a certificate signing request (CSR) from our SSL private keystore
keytool -certreq -keyalg RSA -alias my-ssl -file .\my-ssl.csr -keystore .\my-ssl.jks -keypass pass77 -storepass pass77
# Issue an SSL certificate from the Root-CA private keystore in response to the request (external localhost.foo.bar dns entry optional)
keytool -keypass pass77 -storepass pass77 -validity 3650 -keystore .\my-ca.jks -gencert -alias my-ca -infile .\my-ssl.csr -ext ku:critical=digitalSignature,keyEncipherment -ext eku=serverAuth,clientAuth -ext san=dns:localhost,dns:localhost.foo.bar -ext bc:critical=ca:false -rfc -outfile .\my-ssl.crt
# Import Root-CA certificate into SSL private keystore
keytool -noprompt -import -trustcacerts -alias my-ca -file my-ca.crt -keystore my-ssl.jks -keypass pass77 -storepass pass77
# Import an SSL (chained) certificate into keystore
keytool -import -trustcacerts -alias my-ssl -file my-ssl.crt -keystore my-ssl.jks -keypass pass77 -storepass pass77 -noprompt
Run Code Online (Sandbox Code Playgroud)
完成此操作后,Firefox只需要信任Root-CA证书,并且可以使用GUI或AutoConfig脚本导入.
必须使用新的SSL私有密钥库重新启动SSL服务器,该私有密钥库将包含通过SSL工作的信任链.
由于my-ssl.jks
包含了信任的整个产业链my-ca.jks
,my-ca.crt
,my-ssl.crt
并且my-ssl.csr
都可以安全地删除(假设my-ca.crt
已正确导入)
正如@tresf 和@Zombaya 所说,Firefox 需要两个证书:
授权证书用于签署开发证书。开发证书绑定HTTP端口。Web 服务器侦听该端口的请求。
Windows 开发环境
其他答案解释了在 Java 和 Unix 环境中要做什么。这是我在 Windows 开发环境中所做的。这将创建 Firefox、Chrome 和 Internet Explorer 信任的证书:
使用 C:\Windows\System32\drivers\etc\hosts 文件中的条目覆盖 DNS。
127.0.0.1 dev.brainstorm.com
Run Code Online (Sandbox Code Playgroud)
使用 PowerShell 创建授权和开发证书并将它们存储在本地计算机证书存储中。用您的公司名称和 DNS 条目替换“Brainstorm”。以管理员身份运行 PowerShell。
127.0.0.1 dev.brainstorm.com
Run Code Online (Sandbox Code Playgroud)
授予开发人员在特定 URL 和端口(通过 IIS Express)托管网站和服务的权限。网站使用标准 SSL 端口,服务使用其他端口。为什么?IIS Express 无法在由主机名区分的同一端口上同时托管两个应用程序。他们必须使用不同的端口。
# Create authority certificate.
# TextExtension adds the Server Authentication enhanced key usage and the CA basic contraint.
$authorityCert = New-SelfSignedCertificate `
-Subject "CN=Brainstorm CA,OU=IT,O=Brainstorm Certificate Authority,C=US" `
-KeyAlgorithm RSA `
-KeyLength 4096 `
-KeyUsage CertSign, CRLSign, DigitalSignature, KeyEncipherment, DataEncipherment `
-KeyExportPolicy Exportable `
-NotBefore (Get-Date) `
-NotAfter (Get-Date).AddYears(10) `
-HashAlgorithm SHA256 `
-CertStoreLocation "Cert:\LocalMachine\My" `
-FriendlyName "Brainstorm CA" `
-TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.1", "2.5.29.19={critical}{text}ca=1")
# Create development certificate.
# Sign it with authority certificate.
# TextExtension adds the Server Authentication enhanced key usage.
$devCert = New-SelfSignedCertificate `
-Subject "CN=Brainstorm,OU=Application Development,O=Brainstorm,C=US" `
-DnsName dev.brainstorm.com `
-KeyAlgorithm RSA `
-KeyLength 4096 `
-KeyUsage DigitalSignature, KeyEncipherment, DataEncipherment `
-KeyExportPolicy Exportable `
-NotBefore (Get-Date) `
-NotAfter (Get-Date).AddYears(10) `
-HashAlgorithm SHA256 `
-CertStoreLocation "Cert:\LocalMachine\My" `
-FriendlyName "Brainstorm" `
-TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.1") `
-Signer $authorityCert
# Export authority certificate to file.
$directory = "C:\Users\Erik\Documents\Temp\Certificates\"
if(!(test-path $directory))
{
New-Item -ItemType Directory -Force -Path $directory
}
$authorityCertPath = 'Cert:\LocalMachine\My\' + ($authorityCert.ThumbPrint)
$authorityCertFilename = $directory + "Authority.cer"
Export-Certificate -Cert $authorityCertPath -FilePath $authorityCertFilename
# Import authority certificate from file to Trusted Root store.
Import-Certificate -FilePath $authorityCertFilename -CertStoreLocation "Cert:\LocalMachine\Root"
# Delete authority certificate file.
Remove-Item -Path $authorityCertFilename
Run Code Online (Sandbox Code Playgroud)
如果您需要删除在 URL 上托管网站的开发人员权限:
netsh http add urlacl url=https://dev.brainstorm.com:443/ user="Erik"
netsh http add urlacl url=https://dev.brainstorm.com:44300/ user="Erik"
Run Code Online (Sandbox Code Playgroud)
列出本地计算机存储中的证书。
netsh http delete urlacl url=https://dev.brainstorm.com:443/
netsh http delete urlacl url=https://dev.brainstorm.com:44300/
Run Code Online (Sandbox Code Playgroud)
复制开发证书的指纹(不是权威证书)。
列出绑定到 HTTP 端口的证书。(IIS Express 使用自己的 SSL 证书配置端口 44300 - 44399。)
Get-ChildItem -path "Cert:\LocalMachine\My"
Run Code Online (Sandbox Code Playgroud)
复制应用程序 ID(对于所有 IIS Express 端口 44300 - 44399 都是相同的)。用我们的开发证书替换已经绑定 IIS Express 的网站和服务端口(certhash 是上面的指纹)。您可能需要先运行 netsh,然后输入 http 命令,然后输入 add sslcert... 命令。
netsh http show sslcert
Run Code Online (Sandbox Code Playgroud)
如果您需要从 HTTP 端口解除绑定证书:
netsh http add sslcert hostnameport=dev.brainstorm.com:443 certhash=FE035397A4C44AB591A1D9D4DC0B44074D0F95BA appid={214124cd-d05b-4309-9af9-9caa44b2b74a} certstore=my
netsh http add sslcert hostnameport=dev.brainstorm.com:44300 certhash=FE035397A4C44AB591A1D9D4DC0B44074D0F95BA appid={214124cd-d05b-4309-9af9-9caa44b2b74a} certstore=my
Run Code Online (Sandbox Code Playgroud)
在 Visual Studio 中,配置服务的 launchSettings.json 文件(在 Properties 文件夹中):
netsh http delete sslcert hostnameport=dev.brainstorm.com:443
netsh http delete sslcert hostnameport=dev.brainstorm.com:44300
Run Code Online (Sandbox Code Playgroud)
在 Visual Studio 中,配置网站的 launchSettings.json 文件(在 Properties 文件夹中):
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "https://dev.brainstorm.com:44300/",
"sslPort": 44300
}
},
"profiles": {
"Default": {
"commandName": "IISExpress",
"use64Bit": true
}
}
}
Run Code Online (Sandbox Code Playgroud)
配置 IIS Express(在隐藏的 .vs/config 文件夹中):
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "https://dev.brainstorm.com/",
"sslPort": 443
}
},
"profiles": {
"Default": {
"commandName": "IISExpress",
"launchBrowser": true,
"use64Bit": true
}
}
}
Run Code Online (Sandbox Code Playgroud)
在 Firefox 中,导航到 about:config 并将 security.enterprise_roots.enabled 参数设置为 true。
归档时间: |
|
查看次数: |
10616 次 |
最近记录: |