2.9 KiB
2.9 KiB
ACME Staging Implementation Summary
What Was Added
Added support for Let's Encrypt staging environment to prevent rate limiting during development and testing.
Changes Made
1. Configuration (backend/internal/config/config.go)
- Added
ACMEStaging boolfield toConfigstruct - Reads from
CPM_ACME_STAGINGenvironment variable
2. Caddy Manager (backend/internal/caddy/manager.go)
- Added
acmeStaging boolfield toManagerstruct - Updated
NewManager()to acceptacmeStagingparameter - Passes
acmeStagingtoGenerateConfig()
3. Config Generation (backend/internal/caddy/config.go)
- Updated
GenerateConfig()signature to acceptacmeStaging bool - When
acmeStaging=true:- Sets
cafield tohttps://acme-staging-v02.api.letsencrypt.org/directory - Applies to both "letsencrypt" and "both" SSL provider modes
- Sets
4. Route Registration (backend/internal/api/routes/routes.go)
- Passes
cfg.ACMEStagingtocaddy.NewManager()
5. Docker Compose (docker-compose.local.yml)
- Added
CPM_ACME_STAGING=trueenvironment variable for local development
6. Tests
- Updated all test files to pass new
acmeStagingparameter - Added
TestGenerateConfig_ACMEStaging()to verify behavior - All tests pass ✅
7. Documentation
- Created
/docs/acme-staging.md- comprehensive guide - Updated
/docs/getting-started.md- added environment variables section - Explained rate limits, staging vs production, and troubleshooting
Usage
Development (Avoid Rate Limits)
docker run -d \
-e CPM_ACME_STAGING=true \
-p 8080:8080 \
ghcr.io/wikid82/cpmp:latest
Production (Real Certificates)
docker run -d \
-p 8080:8080 \
ghcr.io/wikid82/cpmp:latest
Verification
Container logs confirm staging is active:
"ca":"https://acme-staging-v02.api.letsencrypt.org/directory"
Benefits
- No Rate Limits: Test certificate issuance without hitting Let's Encrypt limits
- Safe Testing: Won't affect production certificate quotas
- Easy Toggle: Single environment variable to switch modes
- Default Production: Staging must be explicitly enabled
- Well Documented: Clear guides for users and developers
Test Results
- ✅ All backend tests pass (
go test ./...) - ✅ Config generation tests verify staging CA is set
- ✅ Manager tests updated and passing
- ✅ Handler tests updated and passing
- ✅ Integration verified in running container
Files Modified
backend/internal/config/config.gobackend/internal/caddy/config.gobackend/internal/caddy/manager.gobackend/internal/api/routes/routes.gobackend/internal/caddy/config_test.gobackend/internal/caddy/manager_test.gobackend/internal/caddy/client_test.gobackend/internal/api/handlers/proxy_host_handler_test.godocker-compose.local.yml
Files Created
docs/acme-staging.md- User guideACME_STAGING_IMPLEMENTATION.md- This summary