Internal SSL Certs with Let's Encrypt

Internal SSL Certs with Let's Encrypt

I was reading a great article recently about subdomain enumeration services and it got me thinking about Let's Encrypt and internal domains. It's common to run a split-domain setup where there's a single domain for both Internet-available services and Active Directory, with either yourself and someone else providing external DNS and your domain controllers providing internal DNS. I've run a split-domain setup since I began working with Active Directory (AD); it makes it easier on users and administrators both.

In the early days of Active Directory, there was no free source of externally-signed certificates. Some of the commercial Certificate Authorities - Network Associates, Comodo, etc. - charged $100+ annually for a single cert and required physical confirmation of business ownership before issuance. Some issued wildcard certificates (sometimes requiring additional verification) and typically charged extra for it. As a result, internal websites either stayed HTTP-only or got their own copy of the wildcard cert if one was purchased. In smaller environments (like the ones most of us solo admins inhabit) the issue was limited in scope, but in larger environments not so much. A real world problem I'd run into in several larger organizations with wildcard certificates was that every team in IT seemed to have a copy of the cert and the private key. It was used to secure sites on the Internet, extranets, intranets, development servers, developer workstations, test apps, email services, the list goes on. And once a year (or every 2 - 3 years) when this certificate expired the new certificate (plus private key!) got emailed around the company more than directions to the Christmas party. And if there became a reason to revoke or reissue the certificate the process was repeated. There was absolutely no security around the cert, and most importantly the private key. Because it was deployed on so many insecure systems, the attack surface became a lush expanse, ripe for the picking.

The flip side of wildcard certificates in the early days were privately-signed (but valid) certificates issued from an Active Directory Certificate Authority (CA) running Active Directory Certificate Services (AD CS). It was relatively easy to set up and on a corporate LAN root certificate trust was easy to manage. AD CS also offered identity management through AD, lifecycle management, client authentication, and centralized management through Group Policy. The only catch? If your machines weren't Windows, weren't domain members, or weren't able to communicate with AD, you were back to square one.

For the solo admin, the AD CS infrastructure was overkill; all most of us really needed were valid SSL certificates for our internal and external domains. The wildcard cert option was not a horrible solution, but for the reasons mentioned above I'm a bit leery of issuing wildcard certs, especially for the protection of both internal and external - and development and production - systems. And spending $500 or $600/year buying certificates isn't going to break the bank, but if you're really on a shoestring budget protecting development sites isn't going to be high on your list. Enter Let's Encrypt.

For anyone not familiar, Let's Encrypt is a non-profit certificate authority that was founded in 2013 by the Internet Security Research Group whose founding sponsors included Mozilla, the EFF, Cisco, and Akamai among others. With Let's Encrypt we can now obtain valid and trusted SSL certificates for free, and with this capability, now is the time to go all-SSL for both internal and external sites. While there are other ways to obtain certificates, my preferred method is to use the letsencrypt command on Linux and export PKCS12 format if needed on Windows. Here's what you'll need:

  1. Register any DNS names that you're generating certificates for and the entries need to point to public IP addresses that are accessible on TCP/443. However, the port only needs to be available while you're requesting the certificate; it can be closed otherwise.
  2. You'll need a Linux system with nothing running on port 443 (or where you can temporarily stop the service using the port).
  3. Finally, you'll need the letsencrypt command; on Debian/Ubuntu it's as simple as apt-get install letsencrypt.

The way the process works, the Let's Encrypt servers simply look up the domain name for which you're requesting a certificate and send a request to the IP address on port 443. Using the letsencrypt app on Linux, a listener is started on TCP/443 to respond to the request. If all goes as planned the request is approved and the certificate, private key, and intermediate chain are saved to your system and ready for use. I'll walk through the process using this site - - as an example.

  1. Assuming letsencrypt is already installed, I'll stop the webserver temporarily to request the cert: systemctl stop nginx
  2. To renew all certificates located under /etc/letsencrypt/live you would use the flag renew. However, since I only want to renew a single certificate, I'll be using the certonly flag (you would also use the certonly flag for a new certificate request). You'll want to use the directory name under /etc/letsencrypt/live/ as the domain name to renew; e.g. mine is, although the certificate contains alternate names for,,, and The command to renew a single certificate is simply: letsencrypt certonly -d  You'll be prompted to either start a temporary webserver or place files in webroot directory; I always choose the temporary webserver option because it's the easiest. The output from the command will be similar to the following:
root@server [~]# letsencrypt certonly -d
Saving debug log to /var/log/letsencrypt/letsencrypt.log

How would you like to authenticate with the ACME CA?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Spin up a temporary webserver (standalone)
2: Place files in webroot directory (webroot)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 1
Plugins selected: Authenticator standalone, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for
Waiting for verification...
Cleaning up challenges

 - Congratulations! Your certificate and chain have been saved at:
   Your key file has been saved at:
   Your cert will expire on 2021-06-14. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot
   again. To non-interactively renew *all* of your certificates, run
   "certbot renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:
   Donating to EFF:          

After the command finishes, you can then start your webserver again. You can view your new certificate using the openssl command:

root@server [~]# openssl x509 -in /etc/letsencrypt/live/ -noout -text
        Version: 3 (0x2)
        Serial Number:
        Signature Algorithm: sha256WithRSAEncryption
        Issuer: C = US, O = Let's Encrypt, CN = R3
            Not Before: Dec 29 19:01:03 2020 GMT
            Not After : Mar 29 19:01:03 2021 GMT
        Subject: CN =
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                RSA Public-Key: (2048 bit)
                Exponent: 65537 (0x10001)
        X509v3 extensions:
            X509v3 Key Usage: critical
                Digital Signature, Key Encipherment
            X509v3 Extended Key Usage:
                TLS Web Server Authentication, TLS Web Client Authentication
            X509v3 Basic Constraints: critical
            X509v3 Subject Key Identifier:
            X509v3 Authority Key Identifier:

            Authority Information Access:
                OCSP - URI:
                CA Issuers - URI:

            X509v3 Subject Alternative Name:
            X509v3 Certificate Policies:

            CT Precertificate SCTs:
                Signed Certificate Timestamp:
                    Version   : v1 (0x0)
                    Log ID    : 44:94:65:2E:B0:EE:CE:AF:C4:40:07:D8:A8:FE:28:C0:
                    Timestamp : Dec 29 20:01:04.006 2020 GMT
                    Extensions: none
                    Signature : ecdsa-with-SHA256
                Signed Certificate Timestamp:
                    Version   : v1 (0x0)
                    Log ID    : F6:5C:94:2F:D1:77:30:22:14:54:18:08:30:94:56:8E:
                    Timestamp : Dec 29 20:01:03.984 2020 GMT
                    Extensions: none
                    Signature : ecdsa-with-SHA256
    Signature Algorithm: sha256WithRSAEncryption

You can issue certificates for any combination of internal domains (up to a maximum of 10 per certificate) by adding multiple "-d" switches. For instance, you could combine all your development sites into a single cert, all production sites, all utility sites, etc. - whatever makes sense in your environment. Personally, I like having multiple sub-domain certs (as opposed to a single wildcard cert) for the reasons discussed above. Once you've obtained the certs you simply move them to the internal servers where they're needed. You can also export to the PKCS12 format for use on Windows, again using the openssl command: openssl pkcs12 -export -out mydomain.pfx -inkey privkey.pem -in cert.pem -certfile chain.pem. You will be prompted for a password to protect the private key contained within the output file that you will use when importing to Windows.

In a nutshell, this is by far the easiest (and cheapest) way to enable SSL for all your internal and external web sites. Although the letsencrypt package will enable automatic renewal, I personally prefer manual renewal and disable the automatic renewal via cron. In 2021, there's no excuse for not enabling SSL for all sites under your control and getting your users acclimated to seeing the lock icon everywhere while getting them out of the habit of accepting certificate warnings.