Python模块,用于从Windows证书存储中提取CA和CRL证书(基于ctypes)。
项目描述
wincertstore提供访问Windows CA和CRL证书的接口。它使用ctypes和通过crypt32.dll的Windows系统证书存储API。
示例
import wincertstore for storename in ("CA", "ROOT"): with wincertstore.CertSystemStore(storename) as store: for cert in store.itercerts(usage=wincertstore.SERVER_AUTH): print(cert.get_pem().decode("ascii")) print(cert.get_name()) print(cert.enhanced_keyusage_names())
SERVER_AUTH是默认增强密钥使用。为了获取任何用途的所有证书,请使用None。该模块还提供了更多OID,如CLIENT_AUTH。
对于没有with语句的Python版本
for storename in ("CA", "ROOT"): store = wincertstore.CertSystemStore(storename) try: for cert in store.itercerts(): print(cert.get_pem().decode("ascii") finally: store.close()
CertFile辅助工具
import wincertstore import atexit import ssl certfile = wincertstore.CertFile() certfile.addstore("CA") certfile.addstore("ROOT") atexit.register(certfile.close) # cleanup and remove files on shutdown) ssl_sock = ssl.wrap_socket(sock, ca_certs=certfile.name, cert_reqs=ssl.CERT_REQUIRED)
需求
Python 2.3到3.3
Windows XP、Windows Server 2003或更高版本
ctypes 1.0.2(Python 2.3和2.4)来自http://sourceforge.net/projects/ctypes/
许可
版权所有(c)2013,2014由Christian Heimes <christian@python.org>
根据贡献者协议许可给 PSF。
有关许可详情,请参阅 https://pythonlang.cn/psf/license。
致谢
http://fixunix.com/openssl/254866-re-can-openssl-use-windows-certificate-store.html
参考文献
变更日志
wincertstore 0.2
发布日期:2013年2月26日
默认情况下,CertSystemStore.itercerts()现在仅限于返回适用于SERVER_AUTH的证书——即从客户端的角度验证TLS/SSL的服务器证书。
添加CERT_CONTEXT.get_name()以获取证书的人类可读名称。
添加CERT_CONTEXT.enhanced_keyusage()以从注册表中获取增强密钥使用和信任设置。该方法返回True或包含OIDs的frozenset。True表示证书适用于任何目的。
CERT_CONTEXT.enhanced_keyusage_names()将OIDs映射到人类可读名称。
添加增强密钥使用(如SERVER_AUTH和CLIENT_AUTH)的常用OIDs。
添加对通用wheel的支持。
添加tox进行Python 2.6到3.3的测试。Python 2.4和2.5是手动测试的。
用于TLS测试的是pypi.python.org:443。
wincertstore 0.1
发布日期:2013年3月22日
初始发布
项目详情
wincertstore-0.2.1.zip的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | ebd681f45f4e156493b4fa54f134b9a171d9c0a8de40ae1a0bc96c3092cb8b12 |
|
MD5 | d8353ce258a15f2b234736e53b1757dc |
|
BLAKE2b-256 | 90717b01b7e37a73200bf52a81a2a9ea71b2d0492a5137258dd6034975c808e1 |
wincertstore-0.2.1-py2.py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | cfedf0047855c3fd2668a4750e951329f68ecf6118b5814026c18f23f127dd93 |
|
MD5 | 2b02e576da55ec6f961386e6c0fac038 |
|
BLAKE2b-256 | 3d82d50da806a22161c74059e59319240c02422d92cede1cbf6c36d5035f9337 |