如何使用OpenSSL创建和信任证书? 用于创建根证书RootCA.bat,现在,为服务器证书创建server.bat,添加到 Windows ,添加到 FireFox ,

如何使用OpenSSL创建有效证书以在IIS中使用HTTPS绑定?

它必须也可以在Firefox和所有其他浏览器中使用 我正在使用IIS 10服务器。
Firefox v70, Firefox Dev 版本v72b5, Chrome v79, Edge v44。我希望 HTTPS 绑定能在所有这些浏览器中使用。

l36468146 回答:如何使用OpenSSL创建和信任证书? 用于创建根证书RootCA.bat,现在,为服务器证书创建server.bat,添加到 Windows ,添加到 FireFox ,

好的。我想,我找到了答案,

必须创建证书真实性才能使用 HTTPS 绑定,因此我们所有的证书都将由此签名。为此,请从此处下载OpenSSL的合适版本:Win32/Win64 OpenSSL Installer for Windows并安装它。然后,为了更快,更轻松地工作,可以制作一些脚本文件,

在运行脚本的文件夹中,添加一个名为#的文件夹。所有的证书文件都将存储在这里。

用于创建根证书RootCA.bat

openssl genrsa -des3 -out #/RootCA.key 4096
openssl req -x509 -new -nodes -sha256 -days 730 -key #/RootCA.key -out #/RootCA.crt -config rootca.csr
openssl pkcs12 -export -out #/RootCA.p12 -inkey #/RootCA.key -in #/RootCA.crt
openssl pkcs12 -export -out #/RootCA.pem -inkey #/RootCA.key -in #/RootCA.crt
openssl pkcs12 -export -out #/RootCA.pfx -inkey #/RootCA.key -in #/RootCA.crt

然后,为RootCA的详细信息创建RootCa.csr

[req]
default_bits = 4096
prompt = no
default_md = sha256
req_extensions = req_ext
distinguished_name = dn

[ dn ]
C=US
ST=New York
L=Rochester
O=Developer
OU=CodeSigner
CN=*.codesigning.in

[ req_ext ]
subjectAltName = @alt_names

[ alt_names ]
DNS.1 = *.codesigning.in

运行RootCA.bat时,它将使用RootCa.csr的详细信息创建证书,并将.pem.pfx.p12连同证书文件一起导出( RootCA.csr和“ RootCA.key”也已创建)。



现在,为服务器证书创建server.bat

openssl req -new -sha256 -nodes -out #/server.csr -newkey rsa:2048 -keyout #/server.key -config server.csr
openssl x509 -req -in #/server.csr -CA #/RootCA.crt -CAkey #/RootCA.key -CAcreateserial -out #/server.crt -days 365 -sha256 -extfile v3.ext
openssl pkcs12 -export -out #/server.p12 -inkey #/server.key -in #/server.crt -chain -CAfile #/RootCA.crt
openssl pkcs12 -export -out #/server.pem -inkey #/server.key -in #/server.crt -chain -CAfile #/RootCA.crt
openssl pkcs12 -export -out #/server.pfx -inkey #/server.key -in #/server.crt -chain -CAfile #/RootCA.crt

当然,要了解详细信息,请创建一个server.csr文件,

[req]
default_bits = 4096
prompt = no
default_md = sha256
req_extensions = req_ext
distinguished_name = dn

[ dn ]
C=US
ST=New York
L=Rochester
O=Developer
OU=Test & Learn
CN=*.localhost.in

[ req_ext ]
subjectAltName = @alt_names

[ alt_names ]
DNS.1 = *.localhost.in

然后,另一个名为v3.ext的文件(我不太了解),

authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature,nonRepudiation,keyEncipherment,dataEncipherment
subjectAltName = @alt_names

[ alt_names ]
DNS.1 = *.localhost.in

再次运行server.bat时,它将使用server.csr的详细信息创建证书,并将.pem.pfx.p12连同证书文件一起导出(还将创建server.csrserver.key)。

注意:您将必须为自定义域修改server.csr(默认情况下,它将为dev.localhost.in域创建)。

!!!警告:您必须记住输入的密码。然后,您可以根据需要修改RootCA.csrRootCA.bat。 (以增加到期时间,修改细节等)

添加到 Windows

当我使用Windows时,我只知道有关导入Windows的信息。要添加窗口,只需单击RootCA.p12文件并将其导入。请记住,您必须在{em>受信任的根证书颁发机构和中级证书颁发机构中信任RootCA

除Firefox以外的所有浏览器都将信任该站点。完成(部分完成)!

您可以在运行中使用 mmc 进行检查。然后使用Ctrl + M来管理单元证书。

添加到 FireFox

因为 FireFox 使用它自己的证书管理器,并且对系统证书没有任何注意。因此,您将必须手动导入RootCA.crt以获得信任,所有继承证书都将被信任。如下, Des Des

现在,导入证书,并简单地添加与证书的HTTPS绑定,并使用任何服务器(甚至是IIS等)托管网站。

本文链接:https://www.f2er.com/2772080.html

大家都在问