Make Letsencrypt use DNS-01 instead of HTTP-01 challenge?

Hi all,

Happy to join this amazing community. I want to use letsencrypt but I don’t want to forward my ports yet. I signed up for a domain, and used the letsencrypt certbot to add a certificate to it with DNS-01 as the preferred challenge. However, when I try to apply letsencrypt, it seems to be using HTTP-01 challenge only, so it doesn’t work. Is there a way to use letsencrypt with DNS-01 challenge? If not, then what are my alternatives?

Every time I access my nextcloud installation I get a warning saying the connection is not secure because letsencrypt won’t apply my certificate. System details below:

Nextcloudi Docker Version v1.34.7

Operating system: Docker running on Windows 10

The issue you are facing: Letsencrypt will not apply certificate

Is this the first time you’ve seen this error? (Y/N): N

Steps to replicate it:

  1. Access Nextcloudpi panel
  2. Click nextencrypt
  3. Fill information and click “apply”

The output of your Nextcloud log in Admin > Logging:

 letsencrypt ] (Fri Aug 27 23:56:48 UTC 2021)
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for [My Domain]
Using the webroot path /var/www/nextcloud for all unmatched domains.
Waiting for verification...
Cleaning up challenges
Failed authorization procedure. [My Domain] (http-01): urn:ietf:params:acme:error:connection :: The server could not connect to the client to verify the domain :: Fetching http://[My Domain]/.well-known/acme-challenge/[Random Numbers and letters]: Connection refused
IMPORTANT NOTES:
- The following errors were reported by the server:

Domain: [My Domain here]
Type: connection
Detail: Fetching
http://[My Domain]/.well-known/acme-challenge/[Random Numbers and letters]:
Connection refused

To fix these errors, please make sure that your domain name was
entered correctly and the DNS A/AAAA record(s) for that domain
contain(s) the right IP address. Additionally, please check that
your computer has a publicly routable IP address and that no
firewalls are preventing the server from communicating with the
client. If you're using the webroot plugin, you should also verify
that you are serving files from the webroot path you provided.

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

I don't know where this is

The output of your Apache/nginx/system log in /var/log/____:

Don't know where this is

Yes there is. But there is some manual work involved one way or another… Or you could use a DNS provider that offers an API for ACME clients like certbot, if you want the certificates to be renewed automatically. Please read here how it works in general…

And here you can find a more details about how to use it…

https://serverfault.com/questions/750902/how-to-use-lets-encrypt-dns-challenge-validation

Maybe also google a liittle, there are tons of tutorials out there.

You could simply open the ports temporarily, obtain the certificate, and then close the ports again. That’s probably the easiest way for now, until you figured out how you wanna set this all up permanently. In the worst case you would have to repeat this procedure after 90 days when the cert expires. If you haven’t already set up permanent port forwarding until then… :slight_smile:

1 Like

Tha la for the response. I have already done the DNS-01 challenge similar to the link you provided.

However, I’m using Nextcloudpi, and the default option to activate Letsencrypt seems to only use the HTTP-01 challenge (I don’t see any way to change it).

I guess I will open the ports temporarily.

Thank you.

i guess these are the lines you are looking for:

ok. that doesn’t answer your question how to change them. one way would be to fork the project on github.
another would be a feature request against nextcloudpi (@nachoparker).
or search for this line in your installation. but i think it won’t be update safe.
(i didn’t look into the details.)

1 Like