Skip to main content

Get Certificate Chain 🌐🔐

PyTests

This Python script retrieves the certificate chain from a website, allowing you to analyze and verify the SSL/TLS certificates of the website. This project is a custom fork of the getCertificateChain project, and the overwhelming majority of credit goes to TheScriptGuy.

Table of Contents

Requirements 📋

Installation

PyPi

To install the package from PyPi, simply run the appropriate command.

pip install get-certificate-chain

GitHub

To install from the GitHub repository, follow these steps:

  1. Clone the repository.
  2. Change the directory to the cloned repository.
  3. Install the package using pip.
git clone https://github.com/cdot65/get_certificate_chain.git
cd get_certificate_chain
pip install .

Usage 🚀

Import into script

To use the package in your script, simply import the package and create an instance of the SSLCertificateChainDownloader object.

To pass arguments into the object, you can use the argparse library:

  1. Import the argparse library.
  2. Import the SSLCertificateChainDownloader object from the package.
  3. Create a python dictionary with the "host" key and value of the domain.
  4. Create an instance of the SSLCertificateChainDownloader object.
  5. Run the downloader object with the parsed arguments.
from get_certificate_chain.download import SSLCertificateChainDownloader

downloader = SSLCertificateChainDownloader()
# Use the downloader object for your needs

You can pass the arguments directly into the object:

from get_certificate_chain.download import SSLCertificateChainDownloader

downloader = SSLCertificateChainDownloader()
downloader.run({'host': 'www.google.com'})

import

Or pass you can use the argparse library to parse the arguments:

import argparse
from get_certificate_chain.download import SSLCertificateChainDownloader

# Add your arguments
args = parser.parse_args()

downloader = SSLCertificateChainDownloader()
downloader.run(args)

You may also specify an output directory when creating an instance of the class:

from get_certificate_chain.download import SSLCertificateChainDownloader

downloader = SSLCertificateChainDownloader(output_directory="/var/tmp")
downloader.run({"host": "www.google.com"})

Command Line CLI

To use the script from the command line, run the following command:

get-certificate-chain --host www.google.com

cli

get-certificate-chain --rm-ca-files

cli

Arguments

  • --host: The host:port pair that the script should connect to. Defaults to www.google.com:443.
  • --rm-ca-files: Remove the certificate files in the current working directory (*.crt, *.pem).
  • --get-ca-cert-pem: Get cacert.pem from the chost.se website to help find Root CA.
  • --log-level: Set the log level. Defaults to INFO.
  • --output-dir: Set the output directory. Defaults to the current working directory.

Contributing

Contributions are welcome! To contribute, please follow these guidelines:

  1. Write tests for your code using pytest. Make sure your tests follow the standards set by the existing tests.
  2. Set up a virtual environment using Poetry. You can install Poetry by following the instructions at https://python-poetry.org/docs/#installation.

To set up a new virtual environment for the project, run the appropriate command.

poetry install

To activate the virtual environment, run the appropriate command.

poetry shell

After making your changes and adding tests, ensure that all tests pass by running the appropriate command.

pytest

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for get-certificate-chain 0.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for get-certificate-chain 0.1.8
File Size Uploaded Provenance
get_certificate_chain-0.1.8.tar.gz 10.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for get-certificate-chain 0.1.8
File Interpreter ABI Platform
get_certificate_chain-0.1.8-py3-none-any.whl Python 3 none any Details

Total release size: 22.0 kB

Release files / get_certificate_chain-0.1.8.tar.gz

Download URL get_certificate_chain-0.1.8.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9bef0b6f162ec15f300accfc910e8a2fb378957606510b89ee157306dce3cb40
BLAKE2b-256 checksum
How to use checksums
ca5af47f0c46645ac4933604217ddcd977e8ac8f6fb11e318c6e5363d07b5665
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.0 CPython/3.11.2 Darwin/22.4.0

Release files / get_certificate_chain-0.1.8-py3-none-any.whl

Download URL get_certificate_chain-0.1.8-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
416846fe89ebfe95ffbf96093162e152c7104238231423898af4e9fb6a4fbc89
BLAKE2b-256 checksum
How to use checksums
ceacf1649b11e5fe5291b6739b0e9de1e7ac687e46a3032bd9770b0c7ebed6de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.0 CPython/3.11.2 Darwin/22.4.0

Security for get-certificate-chain 0.1.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page