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

Closed
by Ghost opened 5 years ago · 16 comments
Ghost commented 5 years ago

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.
Owner

Looking into this now...

Looking into this now...
coolaj86 referenced this issue from a commit 5 years ago
coolaj86 referenced this issue from a commit 5 years ago
Owner
@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
Owner

@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.
Owner

Sorry guys, merging this in now.

Sorry guys, merging this in now.
coolaj86 referenced this issue from a commit 5 years ago
Owner

Published as v1.5.3

Published as v1.5.3
coolaj86 closed this issue 5 years ago
Ghost reopened this issue 5 years ago

@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(); } ```
Owner

@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.
coolaj86 referenced this issue from a commit 5 years ago
coolaj86 referenced this issue from a commit 5 years ago
Owner

Reworked in v3.

Reworked in v3.
coolaj86 closed this issue 4 years ago
Sign in to join this conversation.
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.