很多时候网站都需要使用https,如果是.net开发少不了pfx证书,如果资金充足可以买证书,很多地方都可以买到,如果是自己测试用使用Let's Encrypt生成就可以了,只是有3个月的有效期,3个月重新生成就可以了。
可以到这看Let's Encrypt文档。
1、安装完成之后打开Cerbot,使用命令:
Certbot certonly --manual
2、之后会提示输入生成证书的域名:
Please enter the domain name(s) you would like on your certificate (comma and/or
space separated) (Enter 'c' to cancel):
3、验证域名的方式有很多种,我使用的是使用DNS验证,在DNS种添加TXT记录(_acme-challenge),记录值填写提供的值,添加完成之后继续:
Please deploy a DNS TXT record under the name:
_acme-challenge.***.com.
with the following value:
_CA1XV0CGKn-W0TKXyC1-zxZUIuZpaj08Fbwj_DI-2A
4、验证成功之后会提示生成的证书、私钥和到期时间:
Successfully received certificate.
Certificate is saved at: C:\Certbot\live\***.com\fullchain.pem
Key is saved at: C:\Certbot\live\***.com\privkey.pem
This certificate expires on 2023-03-29.
These files will be updated when the certificate renews.
5、有了证书和私钥就可以使用openssl生成pfx格式的文件:
windows下使用openssl还是挺不好搞的,找了一个已经编译好的openssl,可以使用,这里可以下载。(仅学习使用,生产环境安全性自行判断)
.\openssl pkcs12 -export -out C:\Certbot\live\pfx\***.pfx -inkey C:\Certbot\live\***.com\privkey.pem -in C:\Certbot\live\***.com\fullchain.pem
6、运行命令后会提示输入密钥,这是在导入到IIS中需要的;