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

Add support for DirectAdmin DNS validation #99

Merged
merged 1 commit into from
Mar 14, 2021

Conversation

Platzii
Copy link

@Platzii Platzii commented Mar 14, 2021

linuxserver.io


  • I have read the contributing guideline and understand that I have made the correct modifications

Description:

This PR adds support for DNS validation with DirectAdmin using plugin https://github.com/cybercinch/certbot-dns-directadmin

Benefits of this PR and context:

Currently it is not possible to perform DNS validation when a domain's DNS records are maintained on a (self-hosted) DirectAdmin instance.

How Has This Been Tested?

Built the container, pushed to Docker Hub (https://hub.docker.com/r/simonlepla/swag) and tested it on my setup. Worked well (tested custom DNS propagation time as well).

Settings (docker-compose):

  swag:
    image: simonlepla/swag:directadmin
    container_name: swag
    environment:
      - PUID=1037
      - PGID=65538
      - TZ=Europe/Brussels
      - URL=www.example.com
      - VALIDATION=dns
      - DNSPLUGIN=directadmin
      - PROPAGATION=65
      - EMAIL=letsencrypt@example.com
    volumes:
      - /volume1/docker/swag/config:/config
    ports:
      - 443:443
      - 80:80
    restart: unless-stopped

Logs of the test (domain replaced with www.example.com):

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 01-envfile: executing...
[cont-init.d] 01-envfile: exited 0.
[cont-init.d] 10-adduser: executing...

-------------------------------------
          _         ()
         | |  ___   _    __
         | | / __| | |  /  \
         | | \__ \ | | | () |
         |_| |___/ |_|  \__/


Brought to you by linuxserver.io
-------------------------------------

To support the app dev(s) visit:
Certbot: https://supporters.eff.org/donate/support-work-on-certbot

To support LSIO projects visit:
https://www.linuxserver.io/donate/
-------------------------------------
GID/UID
-------------------------------------

User uid:    1037
User gid:    65538
-------------------------------------

[cont-init.d] 10-adduser: exited 0.
[cont-init.d] 20-config: executing...
[cont-init.d] 20-config: exited 0.
[cont-init.d] 30-keygen: executing...
using keys found in /config/keys
[cont-init.d] 30-keygen: exited 0.
[cont-init.d] 50-config: executing...
Variables set:
PUID=1037
PGID=65538
TZ=Europe/Brussels
URL=www.example.com
SUBDOMAINS=
EXTRA_DOMAINS=
ONLY_SUBDOMAINS=false
VALIDATION=dns
CERTPROVIDER=
DNSPLUGIN=directadmin
EMAIL=letsencrypt@example.com
STAGING=

Using Let's Encrypt as the cert provider
No subdomains defined
E-mail address entered: letsencrypt@example.com
dns validation via directadmin plugin is selected
Different validation parameters entered than what was used before. Revoking and deleting existing certificate, and an updated one will be created
Saving debug log to /var/log/letsencrypt/letsencrypt.log
No match found for cert-path /config/etc/letsencrypt/live/www.example.com/fullchain.pem!
Generating new certificate
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator directadmin, Installer None
Account registered.
Requesting a certificate for www.example.com
Performing the following challenges:
dns-01 challenge for www.example.com
Unsafe permissions on credentials configuration file: /config/dns-conf/directadmin.ini
Successfully added TXT record for _acme-challenge.www.example.com
Waiting 65 seconds for DNS changes to propagate
Waiting for verification...
Cleaning up challenges
Successfully removed TXT record for _acme-challenge.www.example.com
IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/www.example.com/fullchain.pem
   Your key file has been saved at:
New certificate generated; starting nginx
Starting 2019/12/30, GeoIP2 databases require personal license key to download. Please retrieve a free license key from MaxMind,
and add a new env variable "MAXMINDDB_LICENSE_KEY", set to your license key.
[cont-init.d] 50-config: exited 0.
[cont-init.d] 60-renew: executing...
The cert does not expire within the next day. Letting the cron script handle the renewal attempts overnight (2:08am).
[cont-init.d] 60-renew: exited 0.
[cont-init.d] 70-templates: executing...
[cont-init.d] 70-templates: exited 0.
[cont-init.d] 99-custom-files: executing...
[custom-init] no custom files found exiting...
[cont-init.d] 99-custom-files: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
Server ready

Source / References:

https://github.com/cybercinch/certbot-dns-directadmin

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for opening this pull request! Be sure to follow the pull request template!

@Platzii
Copy link
Author

Platzii commented Mar 14, 2021

Build error appears to be caused by a bug in the cargo version used (1.47, which is the default version in alpine 3.13 currently) as pointed out in rust-lang/cargo#9187 :/

@aptalca aptalca self-assigned this Mar 14, 2021
Copy link
Member

@aptalca aptalca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks

@aptalca aptalca merged commit 7f0a3bf into linuxserver:master Mar 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants