Certgen
Certgen is a pure Ruby CLI tool to generate free SSL certificates from Let's Encrypt using DNS-01 verification. Perfect for developers and site owners who use cPanel or manually managed servers and need to upload certificates themselves.
π¦ Setup
-
Clone the repository:
git clone https://github.com/cdrrazan/certgen cd certgen -
Install dependencies:
bundle install
π Global Usage (Recommended)
To run certgen from anywhere without typing the full path, create a symlink in your system bin:
sudo ln -s "$(pwd)/bin/certgen" /usr/local/bin/certgenNow you can simply run:
certgen generate --domain example.com --email user@example.comπ Usage
π§ Generating Certificates
Run the CLI tool from the project directory:
bin/certgen generate --domain example.com --email user@example.comThis above command will overall:
- Generate or reuse your Let's Encrypt account key
- Create DNS-01 challenge instructions
- Wait for your confirmation after DNS is set
- Generate the certificate files
- Zip them for upload to cPanel or any hosting service
π§ Testing with Letβs Encrypt Staging
To avoid hitting rate limits during development or testing, use the Letβs Encrypt staging environment:
certgen test --domain example.com --email you@example.com- This runs the same generation process but against the staging ACME server.
- Useful for verifying DNS setup and automation without generating real certificates.
π Example Output Files
After running, your certs will be saved in:
~/.ssl_output/example.com/
βββ certificate.crt
βββ private_key.pem
βββ ca_bundle.pem
βββ cert_bundle.zip
π§ͺ Testing
The project uses RSpec for testing. To run the full test suite:
bundle exec rspecThe tests include mocks for the ACME API and file system, ensuring safe and fast execution.
βοΈ DNS Setup
You'll be prompted to create a DNS TXT record:
Record Name: _acme-challenge.example.com
Record Type: TXT
Record Value: abc123...
Use https://dnschecker.org to confirm propagation before continuing.
β Requirements
- Ruby >= 3.1
- DNS management access to create TXT records
- cPanel or similar manual SSL upload support
π License
This project is licensed under the MIT License. See the LICENSE file for details.
π Author
Rajan Bhattarai
GitHub β’ Email
π Contributions and issues are welcome β feel free to open a PR or issue on GitHub!