Automated SSL Certificate Management with DNS Challenge Support
A robust certificate management solution that:
- Automates wildcard SSL certificate issuance and renewal using DNS challenges
- Integrates with Nginx Proxy Manager (NPM) for certificate management
- Supports United Domains DNS provider
- Handles certificate renewals non-interactively after initial setup
- 🔒 Wildcard Certificates: Support for multiple wildcard domains
- 🤖 Automated DNS Challenges: Handles DNS verification automatically
- 🔄 Auto Renewal: Non-interactive renewal process
- 🔌 NPM Integration: Direct integration with Nginx Proxy Manager
- 📝 TypeScript Support: Written in TypeScript for better maintainability
- Node.js 20+
- Nginx Proxy Manager instance
- United Domains account
certbotinstalled on the systemdigcommand available for DNS verification
Required environment variables:
# United Domains Credentials
UD_USERNAME=your-ud-username
UD_PASSWORD=your-ud-password
# Nginx Proxy Manager Configuration
NPM_BASE_URL=http://your-npm-instance:81
NPM_IDENTITY=your-npm-email
NPM_SECRET=your-npm-password
# Domain Configuration
DOMAIN=your-base-domain.com
WILDCARDS="*.your-domain.com,*.subdomain.your-domain.com"-
Clone this repository:
git clone https://github.com/kibibit/cert-management.git cd cert-management -
Install dependencies:
npm install
-
Build the project:
npm run build
-
Pull the Docker image:
docker pull kibibitopensrc/cert-management:latest
Available tags:
latest: Latest stable releasevX.Y.Z: Specific version (e.g.,v1.0.0)vX.Y: Minor version (e.g.,v1.0)vX: Major version (e.g.,v1)
View all available tags on Docker Hub
-
Run the container with your environment variables:
docker run -d \ -e NPM_BASE_URL=http://your-npm-instance:81 \ -e NPM_IDENTITY=your-npm-email \ -e NPM_SECRET=your-npm-password \ -e UD_USERNAME=your-ud-username \ -e UD_PASSWORD=your-ud-password \ -e WILDCARDS="*.your-domain.com,*.subdomain.your-domain.com" \ -v /path/to/certificates:/root/kb-certs \ kibibitopensrc/cert-management:latest
-
Set up your environment variables (see above section)
-
Run the certificate maintenance script:
# Using npm npm run start # Using ts-node (development) npm run start:dev
You can also provide configuration via command line arguments:
npx ts-node src/cert-maintenance.ts \
--base-url=http://your-npm-instance:81 \
--identity=your-npm-email \
--secret=your-npm-password \
--domain=your-domain.com \
--wildcards="*.your-domain.com,*.other-domain.com" \
--dry-run# Install dependencies
npm install
# Run in development mode
npm run start:dev
# Build the project
npm run build
# Run linting
npm run lint
# Fix linting issues
npm run lint:fix- The script checks for existing valid certificates in NPM for each wildcard domain
- If a certificate needs renewal:
- Initiates certbot DNS challenge
- Uses United Domains API to set required DNS records
- Verifies DNS propagation
- Obtains the certificate from Let's Encrypt
- Uploads the new certificate to NPM
- Updates NPM proxy hosts to use the new certificate
- Cleanup is performed automatically
- First-time certificate issuance requires DNS verification
- The script expects certbot configuration in
kb-certsdirectory - DNS propagation checks can take several minutes
- Uses dig with trace for reliable DNS verification
- Certificates are stored in NPM after issuance
- Author - Neil Kalman
- Website - https://github.com/kibibit
- StackOverflow - thatkookooguy
- Twitter - @thatkookooguy
- Twitter - @kibibit_opensrc
This project is MIT licensed.