https://github.com/leogregianin/python-digital-certificate
Read digital certificate (pfx and p12 files) in Python
https://github.com/leogregianin/python-digital-certificate
digital-certificate p12 pfx-format python x509 x509certificates
Last synced: 4 months ago
JSON representation
Read digital certificate (pfx and p12 files) in Python
- Host: GitHub
- URL: https://github.com/leogregianin/python-digital-certificate
- Owner: leogregianin
- License: mit
- Created: 2021-03-09T02:45:40.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-05-03T12:41:58.000Z (over 1 year ago)
- Last Synced: 2025-04-12T03:13:49.730Z (6 months ago)
- Topics: digital-certificate, p12, pfx-format, python, x509, x509certificates
- Language: Python
- Homepage: https://leogregianin.github.io/python-digital-certificate/
- Size: 43 KB
- Stars: 19
- Watchers: 4
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Read digital certificate (pfx and p12 files) in Python
[](https://pypi.org/project/python-digital-certificate/)[](https://github.com/leogregianin/python-digital-certificate/actions/workflows/main.yml)
## Install
From source:
```sh
$ python setup.py install
```From PyPi:
```sh
$ pip install python-digital-certificate
```## Development
Create virtual environment
```sh
$ virtualenv .venv
$ source .venv/bin/activate
```Install Dependencies
```sh
$ pip install .
```## Tests
Run
```sh
$ python -m unittest
```## Using
The package can be used with the pfx or p12 file, being the pfx file path or the binary file content```python
from digital_certificate.cert import Certificate
# Instantiate the class with the file path or the binary file content
_cert = Certificate(
pfx_file="./pfx-files/test_file.pfx",
password=b"123456"
)# Read PFX file
_cert.read_pfx_file()# Get Serial Number
print(_cert.serial_number())# Get not valid before date
print(_cert.not_valid_before())# Get not valid after date
print(_cert.not_valid_after())# Get subject name
print(_cert.subject())# Get owner name
print(_cert.common_name())# Get Issuer name
print(_cert.issuer())
```### Using the binary content
If one already have the file in memory, the package can be used instantiating the class as following```python
_cert = Certificate(
pfx_file=binary_file_content,
password=b"123456"
)
```