随着Firefox 54的最近升级,我的自签名from django.db import models
class User(models.Model):
firstName = models.CharField(max_length=200)
lastName = models.CharField(max_length=200)
def __str__(self):
return self.firstName + ' - ' + self.lastName
class UI(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
SSL证书不再受信任。
我一直在使用Firefox AutoConfigure script来安装此证书,这项技术已成功运作了好几年。 Firefox使用自己的证书存储localhost
,其中包含证书,使用Firefox首选项,高级版,证书,查看证书,权限进行验证。
这在MacOS和Windows上都是可重现的。我已附上样本证书以供参考。这与我们安装的相同。
Firefox 54有什么变化?我已审核了changelog,但无法找到与信任证书相关的具体内容。
编辑:链接到很可能引入此更改的Firefox错误:firefox
#1294580
cert8.db
答案 0 :(得分:10)
受到@tresf答案的启发,主要基于博客帖子How to Create Your Own SSL Certificate Authority for Local HTTPS Development
Brad Touesnard,我使用absolute
创建了一组命令。
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
添加到您的浏览器/钥匙串,以信任由新根证书签名的证书
将myCa.pem
和example.com.crt
添加到您的网络服务器配置中以对您的域名进行签名
答案 1 :(得分:9)
要模仿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
完成此操作后,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
已正确导入)
答案 2 :(得分:4)
正如@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
创建权限和开发证书,并使用PowerShell将它们存储在本地计算机证书存储中。替代"头脑风暴"使用您的公司名称和DNS条目。以管理员身份运行PowerShell。
# 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
授予开发人员在特定URL和端口(通过IIS Express)托管网站和服务的权限。对网站使用标准SSL端口,使用另一个端口进行服务。为什么? IIS Express无法同时在由主机名区分的同一端口上托管两个应用程序。他们必须使用不同的端口。
netsh http add urlacl url=https://dev.brainstorm.com:443/ user="Erik"
netsh http add urlacl url=https://dev.brainstorm.com:44300/ user="Erik"
如果您需要删除开发人员在网址上托管网站的权限:
netsh http delete urlacl url=https://dev.brainstorm.com:443/
netsh http delete urlacl url=https://dev.brainstorm.com:44300/
列出本地计算机商店中的证书。
Get-ChildItem -path "Cert:\LocalMachine\My"
复制开发证书的指纹(而非权威证书)。
列出绑定到HTTP端口的证书。 (IIS Express使用自己的SSL证书配置端口44300 - 44399。)
netsh http show sslcert
复制应用程序ID(对于所有IIS Express端口44300 - 44399,它都是相同的)。将已使用IIS Express绑定的网站和服务端口替换为我们的开发证书(certhash是上面的指纹)。您可能需要先运行netsh,然后输入http命令,然后输入add sslcert ... command。
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
如果您需要从HTTP端口取消绑定证书:
netsh http delete sslcert hostnameport=dev.brainstorm.com:443
netsh http delete sslcert hostnameport=dev.brainstorm.com:44300
在Visual Studio中,配置服务的launchSettings.json文件(在“属性”文件夹中):
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "https://dev.brainstorm.com:44300/",
"sslPort": 44300
}
},
"profiles": {
"Default": {
"commandName": "IISExpress",
"use64Bit": true
}
}
}
在Visual Studio中,配置网站的launchSettings.json文件(在“属性”文件夹中):
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "https://dev.brainstorm.com/",
"sslPort": 443
}
},
"profiles": {
"Default": {
"commandName": "IISExpress",
"launchBrowser": true,
"use64Bit": true
}
}
}
配置IIS Express(隐藏的.vs / config文件夹中):
<sites>
<site name="Website" id="1" serverAutoStart="true">
<application path="/">
<virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite" />
</application>
<bindings>
<binding protocol="https" bindingInformation="*:443:dev.brainstorm.com" />
</bindings>
</site>
<site name="Service" id="2">
<application path="/">
<virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\IIS Service" />
</application>
<bindings>
<binding protocol="https" bindingInformation="*:44300:dev.brainstorm.com" />
</bindings>
</site>
<siteDefaults>
<logFile logFormat="W3C" directory="%IIS_USER_HOME%\Logs" />
<traceFailedRequestsLogging directory="%IIS_USER_HOME%\TraceLogFiles" enabled="true" maxLogFileSizeKB="1024" />
</siteDefaults>
<applicationDefaults applicationPool="Clr4IntegratedAppPool" />
<virtualDirectoryDefaults allowSubDirConfig="true" />
</sites>
在Firefox中,导航到about:config并将security.enterprise_roots.enabled参数设置为true。
答案 3 :(得分:0)
您可能想要做的是生成另一个自签名证书,其中包含与您试图信任的主题,发行者和公钥相同的主题,发行者和公钥。但是,您不希望使用&#34; basicConstraints:cA&#34;而不是终端实体扩展,而是指定它是CA证书。并且它可以使用&#34; keyUsage:cRLSign,keyCertSign&#34;颁发证书。添加nameConstraints扩展名以限制它仅适用于某组域,这也是一个好主意。如果您将该证书添加到Firefox的信任数据库中,一切都应该像以前一样工作。