Giter Site home page Giter Site logo

leogregianin / python-digital-certificate Goto Github PK

View Code? Open in Web Editor NEW
18.0 4.0 6.0 41 KB

Read digital certificate (pfx and p12 files) in Python

Home Page: https://leogregianin.github.io/python-digital-certificate/

License: MIT License

Python 100.00%
digital-certificate python x509 x509certificates pfx-format p12

python-digital-certificate's Introduction

Read digital certificate (pfx and p12 files) in Python

PyPIpython-digital-certificate

Install

From source:

$ python setup.py install

From PyPi:

$ pip install python-digital-certificate

Development

Create virtual environment

$ virtualenv .venv
$ source .venv/bin/activate

Install Dependencies

$ pip install .

Tests

Run

$ 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

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

_cert = Certificate(
    pfx_file=binary_file_content,
    password=b"123456"
)

python-digital-certificate's People

Contributors

felipeffm avatar garzuze avatar leogregianin avatar pyup-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

python-digital-certificate's Issues

Initial Update

The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.

How to I use this certificate in requests.post ?

root@ubuntu:/home# python3
Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from digital_certificate.cert import Certificate
>>> _cert = Certificate(pfx_file="webmethoduat.pfx", password=b"NBF@123456")
>>> 
>>> _cert.read_pfx_file()
>>> 

Sign files

  • Sign pdf file
  • Sign txt file
  • Sign xml file

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.