Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with OVH plugin for creating/renewing certificates #537

Closed
mirkoglisenti opened this issue Feb 28, 2024 · 8 comments
Closed

Problem with OVH plugin for creating/renewing certificates #537

mirkoglisenti opened this issue Feb 28, 2024 · 8 comments
Assignees
Labels
question Further information is requested

Comments

@mirkoglisenti
Copy link

When you start the creation (with New-PACertificate) or you submit the renewal of a existing certificate you get an error during the Submit-ChallengeValidation phase.

Error:

Submit-ChallengeValidation: C:\Program Files\WindowsPowerShell\Modules\Posh-ACME\4.20.0\Public\New-PACertificate.ps1:253Line |
253 | Submit-ChallengeValidation
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
| { "message": "Query out of time", "httpCode": "400 Bad Request", "errorCode": "QUERY_TIME_OUT" }

@rmbolger rmbolger self-assigned this Feb 29, 2024
@rmbolger rmbolger added the question Further information is requested label Feb 29, 2024
@rmbolger
Copy link
Owner

Hi @mirkoglisenti. Can you rerun the command that is failing with the -Verbose parameter and post the output here?

@mirkoglisenti
Copy link
Author

New-PACertificate -Domain *.blnservice.it, *.portal.blnservice.it, blnservice.it -Plugin OVH, OVH, OVH -PluginArgs $pArgs -Verbose

DETTAGLIATO: Updating directory info from https://acme-v02.api.letsencrypt.org/directory
DETTAGLIATO: Using ACME Server https://acme-v02.api.letsencrypt.org/directory
DETTAGLIATO: Using account 381216470
DETTAGLIATO: Order name not specified, using '!.blnservice.it'
DETTAGLIATO: Creating a new order '!.blnservice.it' for *.blnservice.it, *.portal.blnservice.it, blnservice.it
DETTAGLIATO: Publishing challenge for Domain blnservice.it with Token qwkZKWmobOnl2gkl6piwwShfwLF6_zo56s8Dbssbn3I using Plugin
 OVH and DnsAlias ''.
DETTAGLIATO: GET https://eu.api.ovh.com/1.0/domain/zone/_acme-challenge.blnservice.it/record?fieldType=TXT with 0-byte payload

Submit-ChallengeValidation : {"message":"Query out of time","httpCode":"400 Bad Request","errorCode":"QUERY_TIME_OUT"}
In C:\Program Files\WindowsPowerShell\Modules\Posh-ACME\4.20.0\Public\New-PACertificate.ps1:253 car:9
          Submit-ChallengeValidation
          ~~~~~~~~~~~~~~~~~~~~~~~~~~
      CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Submit-ChallengeValidation], Web 
   Exception
      FullyQualifiedErrorId : WebCmdletWebResponseException,Submit-ChallengeValidation

@rmbolger
Copy link
Owner

rmbolger commented Mar 1, 2024

This makes it look like your machine can't reach the OVH API server for some reason. What happens if you try to just make an unauthenticated query directly to the API like this?

Invoke-RestMethod https://eu.api.ovh.com/1.0/domain/zone/_acme-challenge.blnservice.it/record?fieldType=TXT

@mirkoglisenti
Copy link
Author

Invoke-RestMethod https://eu.api.ovh.com/1.0/domain/zone/_acme-challenge.blnservice.it/record?fieldType=TXT -verbose
VERBOSE: Requested HTTP/1.1 GET with 0-byte payload
VERBOSE: Received HTTP/1.1 34-byte response of content type application/json
Invoke-RestMethod:
{
"message": "You must login first"
}

@mirkoglisenti
Copy link
Author

Hi Ryan, I have some updates.
I tried using the credentials (AppKey, AppSecret, and ConsumerKey) to fetch information via a Python script that leverages the OVH API and noticed that the credentials were incorrect.
I then proceeded to create new ones via the website:

https://eu.api.ovh.com/createToken

With these new credentials my Python script works perfectly but Posh-ACME on the virtual machine Windows Server 2019 fall still with the same identical error as before (400 bad request - Query time out).

The only idea I had is that I saw that Posh-ACME makes a call to a GET API on such a formed URI:

https://eu.api.ovh.com/1.0/domain/zone/_acme-challenge.blnservice.it

but there is no zone called _acme-challenge.blnservice.it, there is only the one called blnservice.it.
Could it be that the HTTP request made by the OVH plugin is malformed?

I look forward to hearing from you
Thanks

@rmbolger
Copy link
Owner

rmbolger commented Mar 6, 2024

Sorry for the delay on my responses. Been busy lately.

The plugin is making a query for the _acme-challenge.blnservice.it zone before it checks for blnservice.it just in case one exists. Historically, the call would result in either a 403 or 404 response if it didn't exist or the credentials hadn't been given access to it. I wonder if something in the API changed recently though.

If you're comfortable temporarily modifying the plugin file, you could tweak it so it checks for 400 instead of 403 just to see whether that is indeed the problem. It's on line 442 of the OVH.ps1 file in the Plugins folder. Just literally change 403 to 400, save the file, and force re-import the plugin.

# re-throw anything except a 403 or 404 because they indicate the zone
# either doesn't exist or we haven't been given access to it.
if (403 -eq $_.Exception.Response.StatusCode.value__) {
Write-Debug "$zoneTest either doesn't exist or our credentials haven't been given read access to it."
}
elseif (404 -eq $_.Exception.Response.StatusCode.value__) {
Write-Debug "$zoneTest does not exist"
}
else { throw }

You can also test just the plugin rather than a whole cert run using Publish-Challenge directly like this.

Publish-Challenge blnservice.it (Get-PAAccount) faketoke OVH $pArgs -Verbose

It might be a bit before I can test this myself.

@mirkoglisenti
Copy link
Author

mirkoglisenti commented Mar 7, 2024

Hi Ryan, I think that I've found the real problem.

After a bit of research on the "400 - query time out" error and some education about how OVH wants the query and especially the query headers to be formatted, I discovered that the problem was in the very time that was used as the timestamp to sign the http request: it was a time ahead in time (as if my server was a few seconds in the future).

After solving the time problem via windows w32t commands, I was able to fix the problem and now everything works fine.

So no problem in the Posh-ACME source code, it was a problem with my server and its time.

If the same error happens to others, I hope this helps.

Thank you very much

@rmbolger
Copy link
Owner

rmbolger commented Mar 7, 2024

Whoa, that's crazy that a few seconds of skew would cause that sort of problem. Most auth schemes I've seen that have time based components allow for a lot more wiggle room, like minutes. Congrats on figuring it out though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants