Sign inSign up

bai0012/cert-converter

By bai0012

•Updated over 1 year ago

Converting and monitoring multiple certificate-key pairs into PEM and PFX formats.

Image
Internet of things
0

685

bai0012/cert-converter repository overview

⁠Docker Certificate Converter

This Docker project is designed to process multiple certificate-key pairs from an input directory, convert them to PEM and PFX formats, and monitor their changes.

⁠Features

  1. Multiple Certificate Groups: Processes multiple certificate-key pairs, each consisting of a .crt and a .key file.
  2. Certificate Processing:
    • Copies .crt and .key files to the output directory.
    • Converts them into PEM format (fullchain.pem and private.pem) using openssl.
    • Converts them into a password-less PFX format file.
  3. Change Monitoring: Monitors the MD5 checksums of all certificate files. Re-processes a group if any certificate or key file changes.

⁠Directory Structure

docker-cert-converter/
├── Dockerfile
└── entrypoint.sh

⁠Usage

⁠1. Script: entrypoint.sh

This script processes multiple certificate-key pairs found in the input directory. Each pair should have the same base name (e.g., site1.crt and site1.key).

⁠2. Dockerfile

The Docker image is based on Alpine Linux and includes necessary tools like openssl, bash, coreutils, and jq.

⁠Building the Docker Image

Navigate to the docker-cert-converter directory and run:

docker build -t cert-converter:latest .
⁠Running the Docker Container

Ensure you have the following directories:

  • Input: /path/to/certs (contains your certificate-key pairs)
  • Output: /path/to/output (where processed files will be stored)

Run the container with:

docker run -d \
    --name cert-converter \
    -v /path/to/certs:/certs:ro \
    -v /path/to/output:/output \
    cert-converter:latest
⁠Parameters
  • -d: Run the container in detached mode.
  • --name cert-converter: Name the container cert-converter.
  • -v /path/to/certs:/certs:ro: Mount the host's /path/to/certs directory to the container's /certs directory as read-only.
  • -v /path/to/output:/output: Mount the host's /path/to/output directory to the container's /output directory.
⁠Monitoring

Check the container logs to verify operations:

docker logs -f cert-converter
⁠Manual Execution

To manually trigger the processing script:

docker exec -it cert-converter /bin/sh
# Then execute
/app/entrypoint.sh

⁠Notes

  1. File Naming: Ensure each certificate-key pair has the same base name (e.g., site1.crt and site1.key).
  2. Permissions:
    • Ensure the container has read access to the input directory.
    • Ensure the container has write access to the output directory.
  3. Error Handling: Basic error handling is included. Customize as needed for enhanced logging and error management.
  4. Interval Adjustment: The script checks for changes every 24 hours by default. Adjust the sleep command for different intervals.
  5. Environment Variables: Consider using environment variables for configuring paths, intervals, and other settings.

Tag summary

Content type

Image

Digest

sha256:b52d5724d…

Size

8 MB

Last updated

over 1 year ago

docker pull bai0012/cert-converter