作者 by nkdns / 2024-07-14 / 暂无评论 / 335 个足迹
基于上一篇文章,申请的证书暂时还无法在Windows平台的IIS中使用,不过可以简单转换一下。
'''python
from OpenSSL import crypto
with open('full.pem','rb') as full_file:
fullchain = crypto.load_certificate(crypto.FILETYPE_PEM,full_file.read())
with open('key.pem','rb') as key_file:
pemkey = crypto.load_privatekey(crypto.FILETYPE_PEM,key_file.read())
pk12 = crypto.PKCS12()
pk12.set_privatekey(pemkey)
pk12.set_certificate(fullchain)
outpassword = input('导出密码:')
with open('./test/ToPFX/cert.pfx','wb') as cert_file:
cert_file.write(pk12.export(passphrase=outpassword))
'''
使用上述代码即可实现转换
独特见解