fbett / le-acme2-php

LetsEncrypt client library for ACME v2 written in PHP.
MIT License
30 stars 15 forks source link

$order->authorize always returns false for new orders #3

Closed dondon2d closed 6 years ago

dondon2d commented 6 years ago

Is there any way to wait for the authorization to finish? For new orders the script needs to be ran twice to generate the certificates. Thanks!

fbett commented 6 years ago

Hi! Yeah, this library tries not to block the current process. But the LetsEncrypt servers need some time f.e. to generate the certificate, to check the http auth.. Because of this it is currently necessary to run a script multiple times.

Normally that's not a problem, if there is a cronjob.

But you could try to pause the current process by adding: sleep(30); This would halt the process for 30 seconds.

Alternativ:

while(true) {
    if($order->authorized())
        break;
    sleep(30);
}

This would retry, until the order is authorized

But keep in mind: It would be possible that the LetsEncrypt servers need much more time, f.e. minutes or hours to finish a specific step. This is not specified.

dondon2d commented 6 years ago

I resolved it by doing something similar (added a timeout and looped) but I appreciate the answer. Thank you!