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

Zamknięty
opened 2019-01-17 15:18:01 +00:00 by Ghost · 16 komentarzy

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

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

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) { ```
Author

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)"} ```
Author

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?
Author

@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.
Właściciel

Looking into this now...

Looking into this now...
coolaj86 wspomniał(-a) to zgłoszenie z commita 2019-02-05 06:01:01 +00:00
coolaj86 wspomniał(-a) to zgłoszenie z commita 2019-02-05 06:04:31 +00:00
Właściciel
@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
Właściciel

@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?
Author

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

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

@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!
Author

Looking forward for this fix as well.

Looking forward for this fix as well.
Właściciel

Sorry guys, merging this in now.

Sorry guys, merging this in now.
coolaj86 wspomniał(-a) to zgłoszenie z commita 2019-03-14 18:15:23 +00:00
Właściciel

Published as v1.5.3

Published as v1.5.3
coolaj86 zamknął(-ęła) to zgłoszenie 2019-03-14 18:18:08 +00:00
Ghost otworzył(-a) ponownie to zgłoszenie 2019-05-20 09:50:05 +00:00
Author

@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(); } ```
Właściciel

@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 wspomniał(-a) to zgłoszenie z commita 2019-10-21 20:56:25 +00:00
coolaj86 wspomniał(-a) to zgłoszenie z commita 2019-10-21 20:56:25 +00:00
Właściciel

Reworked in v3.

Reworked in v3.
coolaj86 zamknął(-ęła) to zgłoszenie 2020-04-21 07:54:56 +00:00
Zaloguj się, aby dołączyć do tej rozmowy.
Brak etykiety
Brak kamienia milowego
Brak przypisanych
Uczestnicy 2
Powiadomienia
Termin realizacji
Data realizacji jest niewłaściwa lub spoza zakresu. Użyj formatu 'yyyy-mm-dd'.

Brak ustawionego terminu realizacji.

Zależności

No dependencies set.

Reference: coolaj86/acme.js-ARCHIVED#11
No description provided.