🔒 Producing and renewing SSL certificates for domains that use Parspack CDN. A simple, fast way to get them from Let's Encrypt using Certbot and the Parspack DNS API. One script, one command, no trouble.
Automatically obtain and renew Let's Encrypt SSL/TLS certificates using the Parspack DNS API and Certbot DNS-01 challenge. ParspackCERT is a Bash script for automatically creating and removing_acme-challenge TXT records through the Parspack CDN API.
parspackCERT is a single bash script that makes SSL certificate management simple. It uses the Parspack DNS API to automatically add the required _acme-challenge TXT records for domain validation—no manual DNS work needed.d
These days, with heavy internet restrictions in Iran, you often need certificates stored directly on your server. When you need to bypass CDN or turn off proxy mode temporarily, you want your site to work without stopping. This script handles that simply: download, configure once, and you're done. It works for both manual runs and automatic renewal with Certbot.
📋 Before you start:
- Parspack account: Your domain must be added to the Parspack dashboard
- Parspack CDN API token: You can get it from the Parspack dashboard, CDN section. The token must have these permissions: List of Service, Store a DNS record, Delete a DNS record
- Certbot: Must be installed on the system (
sudo apt install certbot) - Python 3: Required for JSON parsing (usually pre-installed)
- curl: Required for API requests (usually pre-installed)
⚡ Simple three steps:
-
Download the script and make it executable (one command):
wget -O parspackCERT https://raw.githubusercontent.com/azolfagharj/parspackCERT/main/parspackCERT && \ chmod +x parspackCERT -
Edit the script and set your Parspack CDN API token:
API_TOKEN="your-parspack-cdn-api-token" -
Run the command for your domain (e.g. yourdomain.ir):
sudo ./parspackCERT -d "yourdomain.ir"
Show usage information:
./parspackCERT
./parspackCERT --help
./parspackCERT -h📁 Certificates are saved automatically in the default Certbot location:
/etc/letsencrypt/live/<cert_name>/fullchain.pem
/etc/letsencrypt/live/<cert_name>/privkey.pem
The certificate name is comes from the first domain you specify.
📖 Behind the scenes, it's simple:
- User runs script: Execute
./parspackCERT -d "example.com"with your domain(s) - Script runs Certbot: The script invokes Certbot with manual DNS challenge mode
- Auth hook: For each domain, Certbot calls the script with
authargument - DNS record creation: The script uses Parspack API to create
_acme-challengeTXT record - Validation: Let's Encrypt checks the TXT record
- Cleanup hook: Certbot calls the script with
cleanupargument - DNS record removal: The script deletes the temporary TXT record
For advanced users and deeper control—wildcards, multiple domains, dry run, and more:
./parspackCERT -d DOMAIN [-d DOMAIN ...] [CERTBOT_OPTIONS]The script accepts the same domain format as Certbot:
| Format | Example | Description |
|---|---|---|
| Single domain | -d "example.com" |
Main domain only |
| Wildcard | -d "*.example.com" |
Covers all subdomains |
| Multiple domains | -d "a.com" -d "b.com" |
Add multiple domains with repeated -d |
| Comma-separated | -d "a.com,b.com,c.com" |
Alternative to multiple -d flags |
Main domain only:
./parspackCERT -d "yourdomain.com"*Wildcard and main domain (covers example.com and .example.com):
./parspackCERT -d "*.example.com" -d "example.com"Multiple domains:
./parspackCERT -d "www.example.com" -d "api.example.com" -d "example.com"Dry run (test without obtaining certificate):
./parspackCERT -d "example.com" --dry-runForce renewal (renew even if not expired):
./parspackCERT -d "example.com" --force-renewal🔄 Set it once and forget it. Certbot schedules automatic renewal (usually twice daily). The script stores the auth and cleanup hooks in the renewal configuration, so Certbot automatically uses parspackCERT—no repeat setup needed.
To test renewal without making changes:
sudo certbot renew --dry-runFor more details, see the Certbot documentation on automated renewals.
| Error | Cause | Solution |
|---|---|---|
| API_TOKEN is empty | Token not set in script | Edit script and add your Parspack CDN API token |
| Invalid or expired API token | Wrong or expired token | Generate new token from Parspack dashboard, CDN section |
| Zone not found for domain | Domain not in Parspack | Add domain to Parspack dashboard first |
| Connection failed | Network or API unreachable | Check network, firewall, API URL |
| certbot is not installed | Certbot missing | Run sudo apt install certbot |
| python3 not found | Python 3 missing | Run sudo apt install python3 |
🔧 Common fixes:
Certificate not renewing automatically:
- Check Certbot timer:
sudo systemctl status certbot.timer - Verify renewal config:
cat /etc/letsencrypt/renewal/yourdomain.com.conf - Ensure
manual_auth_hookandmanual_cleanup_hookpoint to parspackCERT
DNS propagation delay:
- The script waits 25 seconds after creating the TXT record
- For slow DNS, you may need to increase the sleep time in the script
Permission denied:
- Run with sudo when obtaining certificates:
sudo ./parspackCERT -d "example.com"
📄 MIT License. See LICENSE for details. Simple, fast, reliable.
🤝 Enjoying this free project? Consider supporting its development