Skip to main content

Module to assist in the programmatic management of PFX digital certificates

Project description

Python Certificate Manager

Module to assist in the programmatic management of PFX digital certificates on Windows operating system.

Working with A1 digital certificates (e-CPF and e-CNPJ), it is extremely common to need to install and remove them from operating system, or even obtain some information like expiration date or issuer of these objects. So this module was made for provide these operations programmatically and easily.

License Issues Version Last commit Testing Coverage

Table of content

Installing

pip install pycertmanager

Requirements

The module currently supports only Windows operating system and has been tested over Python >= 3.10.

Using

The main entity of the module is the Certificate class which provides the methods for manipulating certificates within the operating system and obtaining relevant information from them.

Examples

from pycertmanager import Certificate

# creating certificate object
certificate = Certificate("mycertificate.pfx", "123456")

# installing certificate on system
certificate.install()

# getting a list with certificate subject data
subject_data = certificate.get_subject_data()

# getting certificate expiration date
expiration_date = certificate.get_expiration_date()

# getting certificate expiration date
issue_date = certificate.get_issue_date()

# removing a certificate
# note that it is a class method and 'pycertmanager.test' is the
# Common Name (CN) of the certificate you want to remove
Certificate.remove("pycertmanager.test")

How does it works

In short, some methods (install and remove) calls PowerShell cmdlets through subprocess built-in module while the remaining methods uses cryptography package primitives.

Support

Found a problema? Please open an Issue describing it or a Pull Request if you know how to fix it. Make sure to write the tests from your code.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Reinforcing, make sure to write tests from your code.

Setup your environment (Windows PowerShell)

# clone this repository
git clone https://github.com/eldersantoss/pycertmanager.git

# create and activate virtual environment
cd pycertmanager
python -m venv venv
& venv/Scripts/Activate

# install dependencies
pip install -r requirements.txt

# run tests
python -m unittest

Roadmap

  • Implement Linux support: the intention is to make this module cross-platform.

License

This project is licensed under the terms of the MIT License.

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

pycertmanager-0.0.4.tar.gz (5.1 kB view hashes)

Uploaded Source

Built Distribution

pycertmanager-0.0.4-py3-none-any.whl (5.4 kB view hashes)

Uploaded Python 3

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