When challenge is in "valid" state setChallenge shouldn't be called again. #11

已关闭
由 Ghost 于 2019-01-17 15:18:01 +00:00 打开 · 16 评论

hi,

According to letsencrypt, the challenge is valid for 30 days.
in acmev2.js implementation, setChallenge is always called, even if the challenge is in valid status.
The expected behavior was to finalize the order immediately without trying to set the challenge again.

hi, According to letsencrypt, the challenge is valid for 30 days. in `acmev2.js` implementation, `setChallenge` is always called, even if the challenge is in `valid` status. The expected behavior was to finalize the order immediately without trying to set the challenge again.
作者

Seeing this error as well:

{"type":"error","text":"Error: Didn't finalize order: Unhandled status '400'. This is not one of the known statuses...\nRequested: 'api.nginx, admin.nginx, nginx'\nValidated: 'api.nginx, admin.nginx, nginx'\n{\n  \"type\": \"urn:ietf:params:acme:error:malformed\",\n  \"detail\": \"Order's status (\\\"valid\\\") was not ready\",\n  \"status\": 400\n}\n\nPlease open an issue at https://git.coolaj86.com/coolaj86/acme-v2.js"}],"stack":"Error: Didn't finalize order: Unhandled status '400'. This is not one of the known statuses...\nRequested: 'api.nginx, admin.nginx, nginx'\nValidated: 'api.nginx, admin.nginx, nginx'\n{\n  \"type\": \"urn:ietf:params:acme:error:malformed\",\n  \"detail\": \"Order's status (\\\"valid\\\") was not ready\",\n  \"status\": 400\n}\n\nPlease open an issue at https://git.coolaj86.com/coolaj86/acme-v2.js\n    at /api/node_modules/acme-v2/node.js:547:29\n    at <anonymous>\n    at process._tickCallback (internal/process/next_tick.js:189:7)"}

When testing with Pebble using version draft-11 & draft-12.

Seeing this error as well: ```json {"type":"error","text":"Error: Didn't finalize order: Unhandled status '400'. This is not one of the known statuses...\nRequested: 'api.nginx, admin.nginx, nginx'\nValidated: 'api.nginx, admin.nginx, nginx'\n{\n \"type\": \"urn:ietf:params:acme:error:malformed\",\n \"detail\": \"Order's status (\\\"valid\\\") was not ready\",\n \"status\": 400\n}\n\nPlease open an issue at https://git.coolaj86.com/coolaj86/acme-v2.js"}],"stack":"Error: Didn't finalize order: Unhandled status '400'. This is not one of the known statuses...\nRequested: 'api.nginx, admin.nginx, nginx'\nValidated: 'api.nginx, admin.nginx, nginx'\n{\n \"type\": \"urn:ietf:params:acme:error:malformed\",\n \"detail\": \"Order's status (\\\"valid\\\") was not ready\",\n \"status\": 400\n}\n\nPlease open an issue at https://git.coolaj86.com/coolaj86/acme-v2.js\n at /api/node_modules/acme-v2/node.js:547:29\n at <anonymous>\n at process._tickCallback (internal/process/next_tick.js:189:7)"} ``` When testing with [Pebble](https://github.com/letsencrypt/pebble/) using version draft-11 & draft-12.
作者

I think it can be easily fixed by adding the condition:

            return challenge.status === 'valid' ? Promise.resolve() : ACME._postChallenge(me, options, results.identifier, challenge);

to the end of:

          return ACME._getChallenges(me, options, authUrl).then(function (results) {
I think it can be easily fixed by adding the condition: ``` return challenge.status === 'valid' ? Promise.resolve() : ACME._postChallenge(me, options, results.identifier, challenge); ``` to the end of: ``` return ACME._getChallenges(me, options, authUrl).then(function (results) { ```
作者

I tried @cojalvo's recommendation but it didn't help. Here's a more complete debug log:

[acme-v2.js] challenge accepted!
{ 'cache-control': 'public, max-age=0, no-cache',
  'content-type': 'application/json; charset=utf-8',
  link:
   '<https://pebble:14000/authZ/CLIDUyHXsnOnYYjVYWECAoabY7Tzx4kc4yrvtHZA2bo>;rel="up"',
  'replay-nonce': 'vGuBG2WmLJWajQjFDqNlKA',
  date: 'Sat, 26 Jan 2019 20:56:53 GMT',
  'content-length': '191',
  connection: 'close' }
{ type: 'http-01',
  url:
   'https://pebble:14000/chalZ/aX0TocDlSsIxP0vwjsbRLKWcKttnI4orzo-6pswvJaI',
  token: 'SXupDAT7M3BErUYvTrt5drBy2780hS1BuxpcPGnwQKs',
  status: 'pending' }

respond to challenge: resp.body:
{ type: 'http-01',
  url:
   'https://pebble:14000/chalZ/aX0TocDlSsIxP0vwjsbRLKWcKttnI4orzo-6pswvJaI',
  token: 'SXupDAT7M3BErUYvTrt5drBy2780hS1BuxpcPGnwQKs',
  status: 'pending' }

[DEBUG] statusChallenge

poll: valid
[greenlock/lib/core.js] removeChallenge called for 'nginx'

[DEBUG] getChallenges

[greenlock/lib/core.js] setChallenge called for 'api.nginx'

[DEBUG] waitChallengeDelay 500

[acme-v2.js] challenge accepted!
{ 'cache-control': 'public, max-age=0, no-cache',
  'content-type': 'application/json; charset=utf-8',
  link:
   '<https://pebble:14000/authZ/CH7hDeExIazjYdFJmNiTxIBUMeDQ3zrR9RDwD1by2Dc>;rel="up"',
  'replay-nonce': '1zsctO5Lm6tJjr_u1deAJg',
  date: 'Sat, 26 Jan 2019 20:56:55 GMT',
  'content-length': '191',
  connection: 'close' }
{ type: 'http-01',
  url:
   'https://pebble:14000/chalZ/7RXDxEfAyHdR7pfhspwT0wCHVlc75l7huoqNSJRUdJ4',
  token: '3uu8ih_fVQMNp1b_Gmmh1wK4hzW4v8fpwQibB3EUUMo',
  status: 'pending' }

respond to challenge: resp.body:
{ type: 'http-01',
  url:
   'https://pebble:14000/chalZ/7RXDxEfAyHdR7pfhspwT0wCHVlc75l7huoqNSJRUdJ4',
  token: '3uu8ih_fVQMNp1b_Gmmh1wK4hzW4v8fpwQibB3EUUMo',
  status: 'pending' }

[DEBUG] statusChallenge

poll: valid
[greenlock/lib/core.js] removeChallenge called for 'api.nginx'
[getCertificate] next.then
finalizeOrder:
finalize: https://pebble:14000/finalize-order/8BufAp29nWAeAmpudeEFmiLB44PS-cAeAjx5DzzSKus
order finalized: resp.body:
{ status: 'processing',
  expires: '2019-01-27T20:56:51Z',
  identifiers:
   [ { type: 'dns', value: 'admin.nginx' },
     { type: 'dns', value: 'api.nginx' },
     { type: 'dns', value: 'nginx' } ],
  finalize:
   'https://pebble:14000/finalize-order/8BufAp29nWAeAmpudeEFmiLB44PS-cAeAjx5DzzSKus',
  authorizations:
   [ 'https://pebble:14000/authZ/CLIDUyHXsnOnYYjVYWECAoabY7Tzx4kc4yrvtHZA2bo',
     'https://pebble:14000/authZ/CH7hDeExIazjYdFJmNiTxIBUMeDQ3zrR9RDwD1by2Dc',
     'https://pebble:14000/authZ/We-3ylmt3JVoknU7DTrCqZyCl-xw8P7R0lgiWSQdBfM' ] }
finalize: https://pebble:14000/finalize-order/8BufAp29nWAeAmpudeEFmiLB44PS-cAeAjx5DzzSKus
order finalized: resp.body:
{ type: 'urn:ietf:params:acme:error:malformed',
  detail: 'Order\'s status ("valid") was not ready',
  status: 400 }
Error: bad status:
{
  "type": "urn:ietf:params:acme:error:malformed",
  "detail": "Order's status (\"valid\") was not ready",
  "status": 400
}
[acme-v2] handled(?) rejection as errback:
Error: Didn't finalize order: Unhandled status '400'. This is not one of the known statuses...
Requested: 'api.nginx, admin.nginx, nginx'
Validated: 'api.nginx, admin.nginx, nginx'
{
  "type": "urn:ietf:params:acme:error:malformed",
  "detail": "Order's status (\"valid\") was not ready",
  "status": 400
}

Please open an issue at https://git.coolaj86.com/coolaj86/acme-v2.js
    at /api/node_modules/acme-v2/node.js:547:29
    at process._tickCallback (internal/process/next_tick.js:68:7)
{"code":400,"data":null,"error":true,"messages":[{"type":"error","text":"Error: Didn't finalize order: Unhandled status '400'. This is not one of the known statuses...\nRequested: 'api.nginx, admin.nginx, nginx'\nValidated: 'api.nginx, admin.nginx, nginx'\n{\n  \"type\": \"urn:ietf:params:acme:error:malformed\",\n  \"detail\": \"Order's status (\\\"valid\\\") was not ready\",\n  \"status\": 400\n}\n\nPlease open an issue at https://git.coolaj86.com/coolaj86/acme-v2.js"}],"stack":"Error: Didn't finalize order: Unhandled status '400'. This is not one of the known statuses...\nRequested: 'api.nginx, admin.nginx, nginx'\nValidated: 'api.nginx, admin.nginx, nginx'\n{\n  \"type\": \"urn:ietf:params:acme:error:malformed\",\n  \"detail\": \"Order's status (\\\"valid\\\") was not ready\",\n  \"status\": 400\n}\n\nPlease open an issue at https://git.coolaj86.com/coolaj86/acme-v2.js\n    at /api/node_modules/acme-v2/node.js:547:29\n    at process._tickCallback (internal/process/next_tick.js:68:7)"}
I tried @cojalvo's recommendation but it didn't help. Here's a more complete debug log: ``` [acme-v2.js] challenge accepted! { 'cache-control': 'public, max-age=0, no-cache', 'content-type': 'application/json; charset=utf-8', link: '<https://pebble:14000/authZ/CLIDUyHXsnOnYYjVYWECAoabY7Tzx4kc4yrvtHZA2bo>;rel="up"', 'replay-nonce': 'vGuBG2WmLJWajQjFDqNlKA', date: 'Sat, 26 Jan 2019 20:56:53 GMT', 'content-length': '191', connection: 'close' } { type: 'http-01', url: 'https://pebble:14000/chalZ/aX0TocDlSsIxP0vwjsbRLKWcKttnI4orzo-6pswvJaI', token: 'SXupDAT7M3BErUYvTrt5drBy2780hS1BuxpcPGnwQKs', status: 'pending' } respond to challenge: resp.body: { type: 'http-01', url: 'https://pebble:14000/chalZ/aX0TocDlSsIxP0vwjsbRLKWcKttnI4orzo-6pswvJaI', token: 'SXupDAT7M3BErUYvTrt5drBy2780hS1BuxpcPGnwQKs', status: 'pending' } [DEBUG] statusChallenge poll: valid [greenlock/lib/core.js] removeChallenge called for 'nginx' [DEBUG] getChallenges [greenlock/lib/core.js] setChallenge called for 'api.nginx' [DEBUG] waitChallengeDelay 500 [acme-v2.js] challenge accepted! { 'cache-control': 'public, max-age=0, no-cache', 'content-type': 'application/json; charset=utf-8', link: '<https://pebble:14000/authZ/CH7hDeExIazjYdFJmNiTxIBUMeDQ3zrR9RDwD1by2Dc>;rel="up"', 'replay-nonce': '1zsctO5Lm6tJjr_u1deAJg', date: 'Sat, 26 Jan 2019 20:56:55 GMT', 'content-length': '191', connection: 'close' } { type: 'http-01', url: 'https://pebble:14000/chalZ/7RXDxEfAyHdR7pfhspwT0wCHVlc75l7huoqNSJRUdJ4', token: '3uu8ih_fVQMNp1b_Gmmh1wK4hzW4v8fpwQibB3EUUMo', status: 'pending' } respond to challenge: resp.body: { type: 'http-01', url: 'https://pebble:14000/chalZ/7RXDxEfAyHdR7pfhspwT0wCHVlc75l7huoqNSJRUdJ4', token: '3uu8ih_fVQMNp1b_Gmmh1wK4hzW4v8fpwQibB3EUUMo', status: 'pending' } [DEBUG] statusChallenge poll: valid [greenlock/lib/core.js] removeChallenge called for 'api.nginx' [getCertificate] next.then finalizeOrder: finalize: https://pebble:14000/finalize-order/8BufAp29nWAeAmpudeEFmiLB44PS-cAeAjx5DzzSKus order finalized: resp.body: { status: 'processing', expires: '2019-01-27T20:56:51Z', identifiers: [ { type: 'dns', value: 'admin.nginx' }, { type: 'dns', value: 'api.nginx' }, { type: 'dns', value: 'nginx' } ], finalize: 'https://pebble:14000/finalize-order/8BufAp29nWAeAmpudeEFmiLB44PS-cAeAjx5DzzSKus', authorizations: [ 'https://pebble:14000/authZ/CLIDUyHXsnOnYYjVYWECAoabY7Tzx4kc4yrvtHZA2bo', 'https://pebble:14000/authZ/CH7hDeExIazjYdFJmNiTxIBUMeDQ3zrR9RDwD1by2Dc', 'https://pebble:14000/authZ/We-3ylmt3JVoknU7DTrCqZyCl-xw8P7R0lgiWSQdBfM' ] } finalize: https://pebble:14000/finalize-order/8BufAp29nWAeAmpudeEFmiLB44PS-cAeAjx5DzzSKus order finalized: resp.body: { type: 'urn:ietf:params:acme:error:malformed', detail: 'Order\'s status ("valid") was not ready', status: 400 } Error: bad status: { "type": "urn:ietf:params:acme:error:malformed", "detail": "Order's status (\"valid\") was not ready", "status": 400 } [acme-v2] handled(?) rejection as errback: Error: Didn't finalize order: Unhandled status '400'. This is not one of the known statuses... Requested: 'api.nginx, admin.nginx, nginx' Validated: 'api.nginx, admin.nginx, nginx' { "type": "urn:ietf:params:acme:error:malformed", "detail": "Order's status (\"valid\") was not ready", "status": 400 } Please open an issue at https://git.coolaj86.com/coolaj86/acme-v2.js at /api/node_modules/acme-v2/node.js:547:29 at process._tickCallback (internal/process/next_tick.js:68:7) {"code":400,"data":null,"error":true,"messages":[{"type":"error","text":"Error: Didn't finalize order: Unhandled status '400'. This is not one of the known statuses...\nRequested: 'api.nginx, admin.nginx, nginx'\nValidated: 'api.nginx, admin.nginx, nginx'\n{\n \"type\": \"urn:ietf:params:acme:error:malformed\",\n \"detail\": \"Order's status (\\\"valid\\\") was not ready\",\n \"status\": 400\n}\n\nPlease open an issue at https://git.coolaj86.com/coolaj86/acme-v2.js"}],"stack":"Error: Didn't finalize order: Unhandled status '400'. This is not one of the known statuses...\nRequested: 'api.nginx, admin.nginx, nginx'\nValidated: 'api.nginx, admin.nginx, nginx'\n{\n \"type\": \"urn:ietf:params:acme:error:malformed\",\n \"detail\": \"Order's status (\\\"valid\\\") was not ready\",\n \"status\": 400\n}\n\nPlease open an issue at https://git.coolaj86.com/coolaj86/acme-v2.js\n at /api/node_modules/acme-v2/node.js:547:29\n at process._tickCallback (internal/process/next_tick.js:68:7)"} ```
作者

Also, curl against one of the authorization URLs shows that the authorization is in status "valid":

curl -k  https://pebble:14000/authZ/CLIDUyHXsnOnYYjVYWECA
{
   "status": "valid",
   "identifier": {
      "type": "dns",
      "value": "nginx"
   },
   "challenges": [
      {
         "type": "http-01",
         "url": "https://pebble:14000/chalZ/aX0TocDlSsIxP0vwjsbRLKWcKttnI4orzo-6pswvJaI",
         "token": "SXupDAT7M3BErUYvTrt5drBy2780hS1BuxpcPGnwQKs",
         "status": "valid",
         "validated": "2019-01-26T20:56:53Z"
      }
   ],
   "expires": "2019-01-26T21:56:53Z"
}

It sounds to me like maybe the order is already finalized but it's still trying to do it again?

Also, curl against one of the authorization URLs shows that the authorization is in status "valid": ``` curl -k https://pebble:14000/authZ/CLIDUyHXsnOnYYjVYWECA { "status": "valid", "identifier": { "type": "dns", "value": "nginx" }, "challenges": [ { "type": "http-01", "url": "https://pebble:14000/chalZ/aX0TocDlSsIxP0vwjsbRLKWcKttnI4orzo-6pswvJaI", "token": "SXupDAT7M3BErUYvTrt5drBy2780hS1BuxpcPGnwQKs", "status": "valid", "validated": "2019-01-26T20:56:53Z" } ], "expires": "2019-01-26T21:56:53Z" } ``` It sounds to me like maybe the order is already finalized but it's still trying to do it again?
作者

@cabloo im not sure that the issue you are facing is the same one i report on.

@cabloo im not sure that the issue you are facing is the same one i report on.
管理员

Looking into this now...

Looking into this now...
coolaj862019-02-05 06:01:01 +00:00 在代码提交中引用了该工单
coolaj862019-02-05 06:04:31 +00:00 在代码提交中引用了该工单
管理员
@cojalvo Would you mind testing this patch? * https://git.coolaj86.com/coolaj86/acme-v2.js/src/branch/skip-valid-challenge * https://git.coolaj86.com/coolaj86/acme-v2.js/commit/f0f9feb519f82c9c766bb467762078220688f187
管理员

@cabloo, I'm not sure what to make of that error report, but I think it deserves a separate issue.

I've never tested Greenlock or ACME.js with faux domain names like that (api.nginx), so I'm not sure how it will handle them.

Perhaps you could set a few example.com domains in your /etc/hosts (such as test.example.com) and see if you still get those errors?

@cabloo, I'm not sure what to make of that error report, but I think it deserves a separate issue. I've never tested Greenlock or ACME.js with faux domain names like that (`api.nginx`), so I'm not sure how it will handle them. Perhaps you could set a few `example.com` domains in your `/etc/hosts` (such as `test.example.com`) and see if you still get those errors?
作者

@coolaj86 i will check that and let you know.
Thanks!

@coolaj86 i will check that and let you know. Thanks!
作者

@coolaj86 i test you fix (skip-valid-challenge) and it looks good.

When it gone be merged?

Thanks!

@coolaj86 i test you fix (skip-valid-challenge) and it looks good. When it gone be merged? Thanks!
作者

Looking forward for this fix as well.

Looking forward for this fix as well.
管理员

Sorry guys, merging this in now.

Sorry guys, merging this in now.
coolaj862019-03-14 18:15:23 +00:00 在代码提交中引用了该工单
管理员

Published as v1.5.3

Published as v1.5.3
coolaj862019-03-14 18:18:08 +00:00 关闭此工单
Ghost 重新打开此问题 2019-05-20 09:50:05 +00:00
作者

@coolaj86 I find a bug in the fix.
When the order is for multi-domains certificate. it may happen that only one of the authorization will be in a valid state and the other is still pending since the user only satisfied a previous challenge for only one of the domains.
By returning from the next() function we skip the validation of the rest of the domains in the order.
The correct fix will be:

   if ("valid" === challenge.status) {
              return next();
            }
@coolaj86 I find a bug in the fix. When the order is for multi-domains certificate. it may happen that only one of the authorization will be in a valid state and the other is still pending since the user only satisfied a previous challenge for only one of the domains. By returning from the `next()` function we skip the validation of the rest of the domains in the order. The correct fix will be: ``` if ("valid" === challenge.status) { return next(); } ```
管理员

@cojalvo Have you tried v1.7.7?

I believe that was already fixed.

@cojalvo Have you tried v1.7.7? I believe that was already fixed.
coolaj862019-10-21 20:56:25 +00:00 在代码提交中引用了该工单
coolaj862019-10-21 20:56:25 +00:00 在代码提交中引用了该工单
管理员

Reworked in v3.

Reworked in v3.
coolaj862020-04-21 07:54:56 +00:00 关闭此工单
登录 并参与到对话中。
未选择标签
未选择里程碑
未指派成员
2 名参与者
通知
到期时间
到期日期无效或超出范围。请使用 'yyyy-mm-dd' 格式。

未设置到期时间。

依赖工单

没有设置依赖项。

参考:coolaj86/acme.js-ARCHIVED#11
没有提供说明。