RogierW / rw-acme-client

Let’s Encrypt ACME client written in PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The local HTTP challenge test for subdomain.domain.com received an invalid response with a 404 status code

dazeron opened this issue · comments

Hello! I'm trying to use this library according to readme. But I test my code on local machine (MAMP), and see the error on step $client->domainValidation()->start($account, $validationStatus[0]);

Fatal error: Uncaught Rogierw\RwAcme\Exceptions\DomainValidationException: The local HTTP challenge test for subdomain.domain.com received an invalid response with a 404 status code. in /Applications/MAMP/htdocs/vendor/rogierw/rw-acme-client/src/Exceptions/DomainValidationException.php:16
Stack trace:
#0 /Applications/MAMP/htdocs/vendor/rogierw/rw-acme-client/src/Support/LocalChallengeTest.php(28): Rogierw\RwAcme\Exceptions\DomainValidationException::localHttpChallengeTestFailed('subdomain.domain.com', '404')

#1 /Applications/MAMP/htdocs/vendor/rogierw/rw-acme-client/src/Endpoints/DomainValidation.php(73): Rogierw\RwAcme\Support\LocalChallengeTest::http('subdomain.domain.com', '4mVHO...', '4mVHO...')

#2 /Applications/MAMP/htdocs/public_html/test.php(51): Rogierw\RwAcme\Endpoints\DomainValidation->start(Object(Rogierw\RwAcme\DTO\AccountData), Object(Rogierw\RwAcme\DTO\DomainValidationData))

#3 {main} thrown in /Applications/MAMP/htdocs/vendor/rogierw/rw-acme-client/src/Exceptions/DomainValidationException.php on line 16

It is important to note, that I'm trying to get the certificate for existing subdomain (not localhost), but my code is executing on MAMP.

Is there difference where the code executed from?
Thank you!

Hi, the LocalChallengeTest verifies if the validation file is present, so a request will be made to subdomain.domain.com/.well-known/acme-challenge/<token>. In your example the validation file could not be found and that's why you get this error.

It doesn't matter where you execute this code.

@RogierW Do I need to place some file to subdomain.domain.com/.well-known/acme-challenge/?
Sorry, I am a noob :(

@dazeron Yes, that's right. You have to create the validation file yourself, with the correct filename and content. See https://github.com/RogierW/rw-acme-client#http-01 for more information.

@RogierW but.. what if I want to create certificate for my user? I have my service service.com (for creating landing pages) with dedicated IP, and I have some users. The user creates landing page and places it at landing.usersite.com, that request my server by CNAME. When user opens landing.usersite.com, he sees landing, that was created by my server. But landing.usersite.com is unavailable via HTTPS (only HTTP), and I want to install SSL-certificate on landing.usersite.com.
Is it possible? I saw some services do it somehow...

@dazeron so landing.usersite.com refers to your server, is that correct? In that case, the approach stays the same. You have to put the validation file in the .well-known/acme-challenge/ directory of the document root of landing.usersite.com.

HTTPS is not necessary for domain validation.

@RogierW I will try it and then come back to close the issue (I hope).

@RogierW How can I install certificate after this command?

if ($order->isFinalized()) {
    $certificateBundle = $client->certificate()->getBundle($order);
}

After you get the certificate, you basically install it on your web server, be it using a control panel with the SSL/TLS feature, or manually in your web server configuration, eg. for apache

https://serverfault.com/a/745285

Different web server have different methods to install your certificate, it really depends on what you use, and no offence, but installing the ssl certificate is not part of the library offered by @RogierW , once you retrieve your certificate, it is your responsibility to install your certificate at this point.

I was writing a reply but @raicabogdan was ahead of me, thanks for your explanation!

It basically comes down to; $certificateBundle contains the certificate and the fullchain and you have to write that to a file. Then include those files in your vhost config.

@RogierW and @raicabogdan thank you!

You're welcome.

I assume your issue has been resolved and therefore I'm closing this issue now.