@certd/acme-client 1.34.1 → 1.34.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Simple and unopinionated ACME client",
4
4
  "private": false,
5
5
  "author": "nmorsman",
6
- "version": "1.34.1",
6
+ "version": "1.34.3",
7
7
  "type": "module",
8
8
  "module": "scr/index.js",
9
9
  "main": "src/index.js",
@@ -18,7 +18,7 @@
18
18
  "types"
19
19
  ],
20
20
  "dependencies": {
21
- "@certd/basic": "^1.34.1",
21
+ "@certd/basic": "^1.34.3",
22
22
  "@peculiar/x509": "^1.11.0",
23
23
  "asn1js": "^3.0.5",
24
24
  "axios": "^1.7.2",
@@ -69,5 +69,5 @@
69
69
  "bugs": {
70
70
  "url": "https://github.com/publishlab/node-acme-client/issues"
71
71
  },
72
- "gitHead": "6c74148c277432f91014bf1eebd824e7423c6f4b"
72
+ "gitHead": "0b152a3cb8ef13113f9612c1bf555755e6f5b209"
73
73
  }
package/src/auto.js CHANGED
@@ -234,6 +234,7 @@ export default async (client, userOpts) => {
234
234
  throw new CancelError("用户取消");
235
235
  }
236
236
 
237
+ const waitDnsDiffuseTime = opts.waitDnsDiffuseTime || 30;
237
238
  try {
238
239
  // eslint-disable-next-line no-await-in-loop
239
240
  await runPromisePa(challengePromises);
@@ -242,8 +243,8 @@ export default async (client, userOpts) => {
242
243
  await wait(60 * 1000);
243
244
  } else {
244
245
  await runPromisePa(localVerifyTasks, 1000);
245
- log("本地校验完成,等待30s")
246
- await wait(30 * 1000)
246
+ log(`本地校验完成,等待${waitDnsDiffuseTime}s`)
247
+ await wait(waitDnsDiffuseTime * 1000)
247
248
  }
248
249
 
249
250
  log("开始向提供商请求挑战验证");
package/src/verify.js CHANGED
@@ -24,22 +24,46 @@ const dns = dnsSdk.promises
24
24
  */
25
25
 
26
26
  async function verifyHttpChallenge(authz, challenge, keyAuthorization, suffix = `/.well-known/acme-challenge/${challenge.token}`) {
27
- const httpPort = axios.defaults.acmeSettings.httpChallengePort || 80;
28
- const challengeUrl = `http://${authz.identifier.value}:${httpPort}${suffix}`;
29
27
 
30
- /* May redirect to HTTPS with invalid/self-signed cert - https://letsencrypt.org/docs/challenge-types/#http-01-challenge */
31
- const httpsAgent = new https.Agent({ rejectUnauthorized: false });
28
+ async function doQuery(challengeUrl){
29
+ log(`正在测试请求 ${challengeUrl} `)
30
+ // const httpsPort = axios.defaults.acmeSettings.httpsChallengePort || 443;
31
+ // const challengeUrl = `https://${authz.identifier.value}:${httpsPort}${suffix}`;
32
+
33
+ /* May redirect to HTTPS with invalid/self-signed cert - https://letsencrypt.org/docs/challenge-types/#http-01-challenge */
34
+ const httpsAgent = new https.Agent({ rejectUnauthorized: false });
35
+
36
+ log(`Sending HTTP query to ${authz.identifier.value}, suffix: ${suffix}, port: ${httpPort}`);
37
+ let data = ""
38
+ try{
39
+ const resp = await axios.get(challengeUrl, { httpsAgent });
40
+ data = (resp.data || '').replace(/\s+$/, '');
41
+ }catch (e) {
42
+ log(`[error] HTTP request error from ${authz.identifier.value}`,e.message);
43
+ return false
44
+ }
45
+
46
+ if (!data || (data !== keyAuthorization)) {
47
+ log(`[error] Authorization not found in HTTP response from ${authz.identifier.value}`);
48
+ return false
49
+ }
50
+ return true
32
51
 
33
- log(`Sending HTTP query to ${authz.identifier.value}, suffix: ${suffix}, port: ${httpPort}`);
34
- const resp = await axios.get(challengeUrl, { httpsAgent });
35
- const data = (resp.data || '').replace(/\s+$/, '');
52
+ }
36
53
 
37
- log(`Query successful, HTTP status code: ${resp.status}`);
54
+ const httpPort = axios.defaults.acmeSettings.httpChallengePort || 80;
55
+ const challengeUrl = `http://${authz.identifier.value}:${httpPort}${suffix}`;
38
56
 
39
- if (!data || (data !== keyAuthorization)) {
40
- throw new Error(`Authorization not found in HTTP response from ${authz.identifier.value}`);
57
+ if (!await doQuery(challengeUrl)) {
58
+ const httpsPort = axios.defaults.acmeSettings.httpsChallengePort || 443;
59
+ const httpsChallengeUrl = `https://${authz.identifier.value}:${httpsPort}${suffix}`;
60
+ const res = await doQuery(httpsChallengeUrl)
61
+ if (!res) {
62
+ throw new Error(`[error] 验证失败,请检查以上测试url是否可以正常访问`);
63
+ }
41
64
  }
42
65
 
66
+
43
67
  log(`Key authorization match for ${challenge.type}/${authz.identifier.value}, ACME challenge verified`);
44
68
  return true;
45
69
  }