Letsencrypt wildcard - Setup wildcard subdomain using letsencrypt and certbot

To get wildcard supported certificates, we need to pass the challenge which requires adding TXT records in your dns records.

To get certificates for single domains, there is no need to modify dns records. Check this link https://micropyramid.com/blog/configure-ssl-with-letsencrypt-and-nginx/  for more info.

Your distribution may have old version of certbot, so we will try with latest certbot from github repository. This solution is based on https://github.com/certbot/certbot/issues/5719, thanks to talyguryn.

git clone https://github.com/certbot/certbot
cd certbot
./certbot-auto certonly --manual -d *.mydomain.com -d mydomain.com --agree-tos --manual-public-ip-logging-ok --preferred-challenges dns-01 --server https://acme-v02.api.letsencrypt.org/directory

Output:

Please deploy a DNS TXT record under the name
_acme-challenge.mydomain.com with the following value:
 
qasdli_thisissometxtvalueherebrrrrrlaisd
 
Before continuing, verify the record is deployed.
-------------------------------------------------------------------------------
Press Enter to Continue
 
-------------------------------------------------------------------------------
Please deploy a DNS TXT record under the name
_acme-challenge.pietrack.com with the following value:
 
aldsfj_onemorevalueheredurrrrrrrrlaisdj
 
Before continuing, verify the record is deployed.
-------------------------------------------------------------------------------
Press Enter to Continue
Waiting for verification...
Cleaning up challenges
 
IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/mydomain.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/mydomain.com/privkey.pem
   Your cert will expire on 2018-07-21. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot-auto
   again. To non-interactively renew *all* of your certificates, run
   "certbot-auto renew"
 - If you like Certbot, please consider supporting our work by:
 
   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

As the above suggests, in your dns records add TXT record, with 

name: _acme-challenge.mydomain.com 

and values

1. qasdli_thisissometxtvalueherebrrrrrlaisd

2. aldsfj_onemorevalueheredurrrrrrrrlaisdj

On successfull verifcation you should have certificates in /etc/letsencrypt/live directory.

Troubleshoot:

Error: Failed authorization procedure.

In this case, check that your TXT records are updated, for that you can run:

host -t txt _acme-challenge.mydomain.com

 

Nginx configuration:

Now that we have certificates in /etc/letsecrypt/live, add those certificates in nginx configuration:

  server {
      listen 443 ssl;
      server_name mydomain.com;
      ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem;
      ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem;
  }

Posted On 24 April 2018 By MicroPyramid


Need any Help in your Project?Let's Talk

Latest Comments
Related Articles
Fabric - Learning part1

Using Fabric, we can configure Linux production server with uwsgi, nginx, vsftpd, mysql, mongodb, postfix, php, python tools, and other relevant pieces of software single-handedly ...

Continue Reading...
Setting Up Sentry - Web Application Event Tracking platform

When you want to track your exception and log mesages in a UI rather than storing it in a file(which we usually do), we can ...

Continue Reading...
Configuring WordPress Blog as sub-directory alongside Django in Nginx

Using regular expressions within Nginx we can bind urls to particular application servers, below we will configure wordpress blog and django site to be deployed ...

Continue Reading...
open source packages

Subscribe To our news letter

Subscribe and Stay Updated about our Webinars, news and articles on Django, Python, Machine Learning, Amazon Web Services, DevOps, Salesforce, ReactJS, AngularJS, React Native.
* We don't provide your email contact details to any third parties