Skip to main content

Python module to extract CA and CRL certs from Windows' cert store (ctypes based).

Project description

wincertstore provides an interface to access Windows’ CA and CRL certificates. It uses ctypes and Windows’s sytem cert store API through crypt32.dll.

Example

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 is the default enhanced key usage. In order to get all certificates for any usage, use None. The module offers more OIDs like CLIENT_AUTH, too.

For Python versions without the with statement:

for storename in ("CA", "ROOT"):
    store = wincertstore.CertSystemStore(storename)
    try:
        for cert in store.itercerts():
            print(cert.get_pem().decode("ascii")
    finally:
        store.close()

See CertOpenSystemStore

CertFile helper:

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)

Requirements

License

Copyright (c) 2013, 2014 by Christian Heimes <christian@python.org>

Licensed to PSF under a Contributor Agreement.

See http://www.python.org/psf/license for licensing details.

Acknowledgements

http://fixunix.com/openssl/254866-re-can-openssl-use-windows-certificate-store.html

http://bugs.python.org/issue17134

References

ChangeLog

wincertstore 0.2

Release date: 26-Feb-2013

  • By default CertSystemStore.itercerts() is now limited to return only certs that are suitable for SERVER_AUTH – that is to validate a TLS/SSL’s server cert from the perspective of a client.

  • Add CERT_CONTEXT.get_name() to get a human readable name of a certificate.

  • Add CERT_CONTEXT.enhanced_keyusage() to get enhanced key usage and trust settings from registry. The method returns either True or a frozenset of OIDs. True means that the certificate is valid for any purpose.

  • CERT_CONTEXT.enhanced_keyusage_names() maps OIDs to human readable names.

  • Add commin OIDs for enhanced key usages like SERVER_AUTH and CLIENT_AUTH.

  • Add support for universal wheels.

  • Add tox for testing Python 2.6 to 3.3. Python 2.4 and 2.5 are tested manually.

  • Use pypi.python.org:443 for TLS tests.

wincertstore 0.1

Release date: 22-Mar-2013

  • Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wincertstore-0.2.zip (15.0 kB view details)

Uploaded Source

Built Distribution

wincertstore-0.2-py2.py3-none-any.whl (8.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file wincertstore-0.2.zip.

File metadata

  • Download URL: wincertstore-0.2.zip
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for wincertstore-0.2.zip
Algorithm Hash digest
SHA256 780bd1557c9185c15d9f4221ea7f905cb20b93f7151ca8ccaed9714dce4b327a
MD5 ae728f2f007185648d0c7a8679b361e2
BLAKE2b-256 dfe1765f9abdd57610b1c6251e4853edddcac60f929cf6c9029200887dde0f9e

See more details on using hashes here.

File details

Details for the file wincertstore-0.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for wincertstore-0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 22d5eebb52df88a8d4014d5cf6d1b6c3a5d469e6c3b2e2854f3a003e48872356
MD5 03510657cf5ed292c9debe22c16edbe0
BLAKE2b-256 d16712f477fa1cc8cbcdc78027c9fb0933ad41daf2e95a29d1cc8f34fe80c692

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page