publishlab / node-acme-client

Simple and unopinionated ACME client for Node.js
MIT License
272 stars 54 forks source link

verifyChallenge should ignore bad certificates when following redirects #65

Closed dweitzman-codaio closed 9 months ago

dweitzman-codaio commented 2 years ago

From https://letsencrypt.org/docs/challenge-types/:

Our implementation of the HTTP-01 challenge follows redirects, up to 10 redirects deep. It only accepts redirects to “http:” or “https:”, and only to ports 80 or 443. It does not accept redirects to IP addresses. When redirected to an HTTPS URL, it does not validate certificates (since this challenge is intended to bootstrap valid certificates, it may encounter self-signed or expired certificates along the way).

I haven't tested this, but I think the code to change would be https://github.com/publishlab/node-acme-client/blob/4335c1e9dd5cd23c8001d486b05bcae847b32783/src/verify.js#L28

Current code: const resp = await axios.get(challengeUrl);

Modified code: const resp = await axios.get(challengeUrl, { httpsAgent: new https.Agent({rejectUnauthorized: false} });