我是pyOpenSSL的新用户,我想用下面的代码制作一个证书
from OpenSSL import crypto as c
cert = c.X509()
cert.add_extensions([
c.X509Extension('crlDistributionPoints', False, 'dirName:/C=US/O=TEST'),
])
这段代码无法运行,谁能帮帮我?pyOpenSSL 似乎不支持 dirName
cert.add_extensions([
c.X509Extension('crlDistributionPoints', False, 'URI:http://somesite') can work
])
最佳答案
我遇到了完全相同的问题,但是我也找不到真正的解决方案,我设法找到了一种通过 Python 完成的解决方法。 在本页中解释了格式 http://openssl.org/docs/apps/x509v3_config.html#CRL-distribution-points以及使用原始 DER 字节的选项。 (部分:任意扩展)
首先从已经具有正确 URI 和 dirName 的证书中“收集”DER 字节。替代方法是使用带有正确 crlDistributionPoint 的 openssl 制作证书,此示例中的 tmpcert 就是此证书。还要弄清楚使用了哪个扩展索引。 get_short_name 将提供扩展的“ key ”,因此搜索 crlDistributionPoint。 收集它使用:
from binascii import hexlify
print tmpcert.get_extension(5).get_short_name()
print hexlify(tmpcert.get_extension(5).get_data())
然后格式化这个输出并在 X509Extension() 的初始化程序中使用它
crypto.X509Extension('crlDistributionPoints', False,
"DER:30:6a:xx:xx:xx:..........:xx:xx")
正如人们所理解的,这完全是一种“硬编码”解决方案,没有以这种方式更改此字段内容的直接方法。
关于python - crlDistributionPoints 目录名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26931070/