One place for hosting & domains

      Certbot

      How To Create Let’s Encrypt Wildcard Certificates with Certbot


      Introduction

      A wildcard certificate is an SSL certificate that can secure any number of subdomains with a single certificate. You may want a wildcard certificate in cases where you need to support multiple subdomains but don’t want to configure them all individually.

      Let’s Encrypt is an SSL certificate authority that grants free certificates using an automated API. In this tutorial you will create a Let’s Encrypt wildcard certificate by following these steps:

      1. Making sure you have your DNS set up correctly
      2. Installing the Certbot plugins needed to complete DNS-based challenges
      3. Authorizing Certbot to access to your DNS provider
      4. Fetching your certificates

      This information is intended to be useful for any Linux distribution and any server software, but you may have to fill in some gaps with further documentation, which we will link to as we go.

      Prerequisites

      This tutorial assumes you already have the following:

      • The Certbot utility installed, version 0.22.0 or later. If you need help installing Certbot, please visit our Let's Encrypt tag page, where you can find installation guides for a variety of Linux distributions and servers. Some common setups are listed below:
      • A domain name, and a DNS provider that is supported by Certbot. See Certbot’s DNS plugin list for a list of supported providers

      Let’s begin by setting up and testing our DNS records.

      Step 1 — Setting up Wildcard DNS

      Before we fetch our wildcard SSL certificate, we should make sure our server is responding to requests on multiple subdomains. This will typically be accomplished by setting up a wildcard DNS record, which looks similar to this:

      *.example.com.   3600  IN  A  203.0.113.1
      

      The * wildcard character is treated as a stand-in for any hostname. This example DNS record would match one.example.com, and two.example.com. It would not match the bare example.com nor would it match one.two.example.com because the * wildcard will only expand to one hostname, not to multiple levels of names.

      Additionally a wildcard DNS record can only have one wildcard character, so *.*.example.com is not allowed.

      Please refer to your DNS provider’s documentation to set up the correct DNS entries. You will want to add either an A or CNAME wildcard record before proceeding.

      Note: If you are using DigitalOcean to manage your DNS, please see How to Create, Edit, and Delete DNS Records in our product documentation for more information.

      To test that your wildcard DNS is working as intended, use the host command to query a few hostnames:

      Be sure to substitute your own domain and hostname above. Also, remember that it sometimes takes a few minutes for DNS records to propagate through the system. If you just added your DNS record and are getting errors, wait a few minutes and try again.

      When the hostname you entered resolves properly, you’ll output similar to the following:

      Output

      one.example.com has address 203.0.113.1

      Otherwise, you’ll see an NXDOMAIN error:

      Output

      Host one.example.com not found: 3(NXDOMAIN)

      Once you’ve verified that multiple subdomains are resolving to your server, you can continue on to the next step, where you’ll configure Certbot to connect to your DNS provider.

      Step 2 — Installing the Correct Certbot DNS Plugin

      Before issuing certificates, Let’s Encrypt performs a challenge to verify that you control the hosts you’re requesting certificates for. In the case of a wildcard certificate, we need to prove that we control the entire domain. We do this by responding to a DNS-based challenge, where Certbot answers the challenge by creating a special DNS record in the target domain. Let’s Encrypt’s servers then verify this record before issuing the certificate.

      In order to connect to your DNS provider, Certbot needs a plugin. Please see Certbot’s DNS plugin list to get the name of the appropriate plugin for your DNS provider.

      For instance, the DigitalOcean provider is called certbot-dns-digitalocean. We can install the certbot-dns-digitalocean plugin on Ubuntu and Debian by installing the following package:

      • sudo apt install python3-certbot-dns-digitalocean

      Other plugins should follow the same naming format. Swap your provider’s name into the command above if you’re using a different service.

      On CentOS and other RPM-based distributions the installation command may be dnf:

      • dnf install python3-certbot-dns-digitalocean

      Or yum:

      • yum install python3-certbot-dns-digitalocean

      You also may need to install additional package repositories on these distributions to get access to the Certbot plugin packages.

      To verify that the plugin was installed correctly, you can ask Certbot to list its current plugins:

      Output

      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * dns-digitalocean Description: Obtain certs using a DNS TXT record (if you are using DigitalOcean for DNS). Interfaces: IAuthenticator, IPlugin Entry point: dns-digitalocean = certbot_dns_digitalocean.dns_digitalocean:Authenticator * standalone Description: Spin up a temporary webserver Interfaces: IAuthenticator, IPlugin Entry point: standalone = certbot.plugins.standalone:Authenticator * webroot Description: Place files in webroot directory Interfaces: IAuthenticator, IPlugin Entry point: webroot = certbot.plugins.webroot:Authenticator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

      In the above output, the dns-digitalocean plugin is listed first, along with the default standalone and webroot plugins.

      When you have verified that the correct plugin is installed, continue on to the next step to configure it.

      Step 3 — Configuring the Certbot Plugin

      Because Certbot needs to connect to your DNS provider and create DNS records on your behalf, you’ll need to give it permission to do so. This involves getting an API token or other authentication information from your DNS provider, and putting it in a secure credentials file that Certbot will later read from.

      Because each provider has a different authentication process, please refer to the documentation for your particular Certbot DNS plugin for more information on what tokens or keys you’ll need to obtain.

      For this example, we will continue using the dns-digitalocean plugin, and will store our credentials in the file ~/certbot-creds.ini.

      We will create this file using the nano text editor:

      This will open up a new blank text file. You’ll want to add your information based on the instructions for your particular DNS provider. DigitalOcean requires a single API token, so it will look like this:

      ~/certbot-creds.ini

      dns_digitalocean_token = 235dea9d8856f5b0df87af5edc7b4491a92745ef617073f3ed8820b5a10c80d2
      

      Be sure to replace the example token above with your own information.

      Save and close the file. If you’re using nano, type CTRL+O (for “write out”), hit ENTER, then CTRL+X to exit.

      After creating the file, you will need to restrict its permissions so that your secret is not leaked to other users. The following chmod command will give read and write access to only your user:

      • chmod 600 ~/certbot-creds.ini

      Once you’ve set up your credentials file, you’re ready to actually request the certificate.

      Step 4 — Retrieving the Certificate

      At this point, retrieving your Let’s Encrypt wildcard certificate is similar to “normal” non-wildcard certificates. The main changes to the process are to specify the DNS-based challenge, and point to our DNS credentials file. Additionally we’ll use a wildcard domain with the -d flag:

      • sudo certbot certonly
      • --dns-digitalocean
      • --dns-digitalocean-credentials ~/certbot-creds.ini
      • -d '*.example.com'

      Note that you cannot use the --nginx or --apache plugins to automatically configure those servers with a wildcard certificate. We use the certonly command instead, to only download the certificate.

      When running the above command, you may be presented with a few questions to answer if this is your first time running Certbot. After answering them, Cerbot will perform the challenge, the Let’s Encrypt servers will verify it, and your new certificate will be downloaded and saved to /etc/letsencrypt/. You should see output similar to the following:

      Output

      IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/example.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/example.com/privkey.pem Your cert will expire on 2021-09-27. 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: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le

      You have successfully generated a wildcard SSL certificate! Your next step is to configure your server application to use it. We’ll link to some resources that can help with this in the next section.

      Conclusion

      In this tutorial you configured Certbot and downloaded a wildcard SSL certificate from the Let’s Encrypt certificate authority. You are now ready to configure your server software to use this certificate to secure its connections.

      For more information on what certificate files were downloaded, and how to handle gracefully restarting your applications when Certbot automatically updates your certificates, take a look at Steps 3 and 4 of our tutorial How To Use Certbot Standalone Mode to Retrieve Let’s Encrypt SSL Certificates on Ubuntu 18.04.



      Source link

      How to Install Certbot for TLS on Ubuntu 18.04


      Updated by Linode

      Written by Rajakavitha Kodhandapani

      What is Certbot?

      Certbot is a tool that automates the process of getting a signed certificate via Let’s Encrypt to use with TLS.

      For most operating system and web server configurations, Certbot creates signed certificates, manages the web server to accept secure connections, and can automatically renew certificates it has created. In most cases, Certbot can seamlessly enable HTTPS without causing server downtime.

      Before You Begin

      Make sure you have registered a Fully Qualified Domain Name (FQDN) and set up A and AAAA DNS records that point to your Linode’s public IPv4 and IPv6 addresses. Consult our DNS Records: An Introduction and DNS Manager guides for help with setting up a domain.

      Note

      If you’re using Apache, change each instance of nginx to apache in the following sections.

      1. Install the Certbot and web server-specific packages, then run Certbot:

        sudo apt-get update
        sudo add-apt-repository ppa:certbot/certbot
        sudo apt-get install python-certbot-nginx
        sudo certbot --nginx
        
      2. Certbot will ask for information about the site. The responses will be saved as part of the certificate:

          
            # sudo certbot --nginx
            Saving debug log to /var/log/letsencrypt/letsencrypt.log
            Plugins selected: Authenticator nginx, Installer nginx
            Enter email address (used for urgent renewal and security notices) (Enter 'c' to
            cancel): [email protected]
            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            Please read the Terms of Service at
            https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
            agree in order to register with the ACME server at
            https://acme-v02.api.letsencrypt.org/directory
            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            (A)gree/(C)ancel: A
        
            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            Would you be willing to share your email address with the Electronic Frontier
            Foundation, a founding partner of the Let's Encrypt project and the non-profit
            organization that develops Certbot? We'd like to send you email about our work
            encrypting the web, EFF news, campaigns, and ways to support digital freedom.
            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            (Y)es/(N)o: N
            No names were found in your configuration files. Please enter in your domain
            name(s) (comma and/or space separated)  (Enter 'c' to cancel): www.rajie.wiki
            Obtaining a new certificate
            Performing the following challenges:
            http-01 challenge for www.example.com
            Waiting for verification...
            Cleaning up challenges
            Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/default
        
            Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            1: No redirect - Make no further changes to the webserver configuration.
            2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
            new sites, or if you're confident your site works on HTTPS. You can undo this
            change by editing your web server's configuration.
            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
            Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/default
            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        
            
        
      3. Certbot will also ask if you would like to automatically redirect HTTP traffic to HTTPS traffic. It is recommended that you select this option.

      4. When the tool completes, Certbot will store all generated keys and issued certificates in the /etc/letsencrypt/live/$domain directory, where $domain is the name of the domain entered during the Certbot certificate generation step.

        Note

        Certbot recommends pointing your web server configuration to the default certificates directory or creating symlinks. Keys and certificates should not be moved to a different directory.

        Finally, Certbot will update your web server configuration so that it uses the new certificate, and also redirects HTTP traffic to HTTPS if you chose that option.

      5. If you have a firewall configured on your Linode, you may need to add Firewall Rules to allow incoming and outgoing connections to the HTTPS service. If you’re using UFW for example, you can enable HTTP and HTTPS traffic with the following commands:

        sudo systemctl start ufw && sudo systemctl enable ufw
        sudo ufw allow http
        sudo ufw allow https
        sudo ufw enable
        

        Note

      This guide is published under a CC BY-ND 4.0 license.



      Source link

      How to Install Certbot for TLS on Debian 10


      Updated by Linode

      Written by Rajakavitha Kodhandapani

      What is Certbot?

      Certbot is a tool that automates the process of getting a signed certificate via Let’s Encrypt to use with TLS.

      For most operating system and web server configurations, Certbot creates signed certificates, manages the web server to accept secure connections, and can automatically renew certificates it has created. In most cases, Certbot can seamlessly enable HTTPS without causing server downtime.

      Before You Begin

      Make sure you have registered a Fully Qualified Domain Name (FQDN) and set up A and AAAA DNS records that point to your Linode’s public IPv4 and IPv6 addresses. Consult our DNS Records: An Introduction and DNS Manager guides for help with setting up a domain.

      Note

      If you’re using Apache, change each instance of nginx to apache in the following sections.

      1. Install the Certbot and web server-specific packages, then run Certbot:

        sudo apt install certbot python-certbot-nginx
        sudo certbot --nginx
        
      2. Certbot will ask for information about the site. The responses will be saved as part of the certificate:

          
        # sudo certbot --nginx
        Saving debug log to /var/log/letsencrypt/letsencrypt.log
        Plugins selected: Authenticator nginx, Installer nginx
        Enter email address (used for urgent renewal and security notices) (Enter 'c' to
        cancel): [email protected]
        
        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        Please read the Terms of Service at
        https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
        agree in order to register with the ACME server at
        https://acme-v02.api.letsencrypt.org/directory
        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        (A)gree/(C)ancel: A
        
        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        Would you be willing to share your email address with the Electronic Frontier
        Foundation, a founding partner of the Let's Encrypt project and the non-profit
        organization that develops Certbot? We'd like to send you email about our work
        encrypting the web, EFF news, campaigns, and ways to support digital freedom.
        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        (Y)es/(N)o: N
        No names were found in your configuration files. Please enter in your domain
        name(s) (comma and/or space separated)  (Enter 'c' to cancel): www.rajie.wiki
        Obtaining a new certificate
        Performing the following challenges:
        http-01 challenge for www.example.com
        Waiting for verification...
        Cleaning up challenges
        Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/default
        
        Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        1: No redirect - Make no further changes to the webserver configuration.
        2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
        new sites, or if you're confident your site works on HTTPS. You can undo this
        change by editing your web server's configuration.
        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
        Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/default
        
        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        
        
        
      3. Certbot will also ask if you would like to automatically redirect HTTP traffic to HTTPS traffic. It is recommended that you select this option.

      4. When the tool completes, Certbot will store all generated keys and issued certificates in the /etc/letsencrypt/live/$domain directory, where $domain is the name of the domain entered during the Certbot certificate generation step.

        Note

        Certbot recommends pointing your web server configuration to the default certificates directory or creating symlinks. Keys and certificates should not be moved to a different directory.

        Finally, Certbot will update your web server configuration so that it uses the new certificate, and also redirects HTTP traffic to HTTPS if you chose that option.

      5. If you have a firewall configured on your Linode, you may need to add Firewall Rules to allow incoming and outgoing connections to the HTTPS service. If you’re using UFW, you can enable HTTP and HTTPS traffic with the following commands:

        sudo systemctl start ufw && sudo systemctl enable ufw
        sudo ufw allow http
        sudo ufw allow https
        sudo ufw enable
        

        Note

      This guide is published under a CC BY-ND 4.0 license.



      Source link