python - 如何在 python 中使用 pyopenssl 模块将证书链转储到 PEM 文件中
问题描述
我想将完整的证书链转储到 PEM 文件中。目前我正在尝试使用 pyOpenSSL 模块,因为 ssl 模块没有提供获取证书链的方法(只有服务器证书下载可用)。
import OpenSSL
def get_cert_chain(address, port=443):
context = Context(SSLv23_METHOD)
client = socket()
client.connect((address, port))
clientSSL = Connection(context, client)
clientSSL.set_connect_state()
clientSSL.do_handshake()
return clientSSL.get_peer_cert_chain()
#The below certificate_chain variable contains the stack of X509 certificates
certificate_chain = get_cert_chain('www.google.com')
目的:我想导入完整的目标 IP 链并在 .pem 文件上运行 keytool 导入以添加到 Wildfly 信任库。但是,X509 类中没有方法可以执行诸如将链转储到 .pem 文件之类的操作以及类似的操作。
为相同添加了下面的屏幕截图-(调试点)
解决方案
推荐阅读
- python - How to group rows, count in one column and do the sum in the other?
- django - Pillow Package的Docker Django安装错误
- apache - 试图通过 .htaccess 禁用以下 HTTP 方法:POST、OPTIONS、GET、HEAD、TRACE
- webpack - svg-sprite-loader with Angular 8 custom webpack config
- java - 无法解析 checkSelfPermission() 或 requestPermissions()
- batch-file - 使用批处理文件替换文件内容中的特定字符
- reactjs - Qt“直通”或“容器”小部件
- angular - 如何在引导模型中设置 [(ngModel)]
- asp.net - 在 asp.net 中使用静态网站调用 SOAP API + WSDL
- reactjs - 我们很抱歉。该卖家不接受以您的货币付款。请返回给卖家,并在react中选择另一种付款方式