1.5 KiB
1.5 KiB
Plan: Add wildcard domain support to SmartAcme
Goal
- Enable SmartAcme to accept wildcard domain inputs like
*.domain.com
or*.sub.example.com
and correctly request and match wildcard certificates.
Steps
- Extend SmartacmeCertMatcher:
- Update
getCertificateDomainNameByDomainName()
to handle wildcard prefixes:- If input starts with
*.
strip the prefix and return the base domain. - For example:
*.example.com
→example.com
*.sub.example.com
→sub.example.com
*.a.b.example.com
→a.b.example.com
- If input starts with
- Ensure existing logic for non-wildcards remains unchanged.
- Update
- Update
SmartAcme.getCertificateForDomain()
:- Detect wildcard inputs (
domainArg.startsWith('*.')
). - For wildcard cases, enforce DNS-01 challenge only (throw error if handlers don't support DNS-01).
- Use the matcher result to request wildcard certificate identifiers (e.g.,
value: '*.baseDomain'
).
- Detect wildcard inputs (
- Update tests:
- Add unit tests in
test/test.certmatcher.ts
for wildcard handling:*.example.com
→example.com
*.sub.example.com
→sub.example.com
*.a.b.example.com
→a.b.example.com
- Add integration stub in
test/test.smartacme.ts
for wildcard input in integration mode:- Call
getCertificateForDomain('*.domain.com')
and expect returned certdomainName
equals*.domain.com
.
- Call
- Add unit tests in
- Update documentation (README.md) if needed.
- Run CI (
pnpm build
&pnpm test
) and fix any regressions.