跳转到主要内容

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()

CertOpenSystemStore

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)

需求

许可

版权所有(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

http://bugs.python.org/issue17134

参考文献

变更日志

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 (16.6 kB 查看哈希值)

上传时间: 源代码

构建分发

wincertstore-0.2.1-py2.py3-none-any.whl (7.8 kB 查看哈希值)

上传时间: Python 2 Python 3

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面