iis - 如何使用 OpenSSL 创建和信任证书?
问题描述
如何使用 OpenSSL 创建有效证书以在 IIS 中使用 HTTPS 绑定?
它必须在 Firefox 和所有其他浏览器中工作,我使用的是 IIS 10 服务器。
以及Firefox v70、Firefox Dev edition v72b5、Chrome v79、Edge v44。我希望HTTPS绑定能够在所有这些浏览器中工作。
解决方案
好的。我想,我找到了答案,
必须创建一个认证权威机构才能使用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
's details create 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
's details 和 Export a创建一个证书.pem
,.pfx
以及.p12
证书文件(aRootCA.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
's details 和 Export a以及.pem
证书文件(a和也被创建)创建一个证书。.pfx
.p12
server.csr
server.key
注意:您必须
server.csr
为您的自定义域修改(默认为dev.localhost.in
域创建)。!!!警告:您必须记住您输入的密码。您可以根据需要修改
RootCA.csr
andRootCA.bat
。(增加过期,修改细节等)
添加到Windows ,
当我使用 Windows 时,我只知道导入到 Windows。要添加 Windows,只需单击RootCA.p12
文件并导入它。RootCA
请记住,您必须信任Trusted Root Certification Authourity和Intermediate Certification Authourity。
除 Firefox 之外的所有浏览器都将信任该站点。工作完成(部分)!!
您可以在运行中使用mmc检查它。Ctrl
然后使用+管理单元证书M
。
添加到火狐,
因为FireFox使用它自己的证书管理器并且不关心系统证书。因此,您将不得不手动导入RootCA.crt
for trust 并且所有继承证书都将受到信任。如下,
现在,导入证书并简单地添加带有证书的 HTTPS 绑定并使用任何服务器(甚至 IIS 等)托管网站。
推荐阅读
- c# - Azure 未在发布 EFCore 2 应用程序时创建数据库架构
- python - Scrapy将产量合并到相同的包中
- python - 如何让用户在 Pymongo 中输入值?
- c# - 在 Office 365 上使用 ExchangeService 创建新任务
- python-3.x - Tkinter 聊天机器人插入文本设计
- python-3.x - 减去值Python36
- php - PDF 文件是否可以定义 0 页或以其他方式导致 0 作为页面大小?
- c# - 如何做像滑块/酒吧这样的铁拳/街头霸王
- python - 无法使用 SQLAlchemy 创建一对一关系
- jquery - 对象中的动态变量名