I Tried Obtaining an SSL Certificate with Let’s Encrypt

Today, I’d like to share my experience using Let’s Encrypt to obtain a web server certificate. Actually, I used Let’s Encrypt for the same purpose about 10 years ago, but the environment has changed since then, and some adjustments were necessary.


目次

Looking Back at Records from 10 Years Ago

When I set up my first web server 10 years ago, I used Let’s Encrypt to get a certificate. The command from my records back then was as follows:

docker run -it --rm -p 443:443 -p 80:80 --name certbot quay.io/letsencrypt/letsencrypt:latest certonly --standalone -d {ドメイン名}

Using this command allowed me to run Certbot inside a Docker container and easily obtain a certificate. However, with the passage of time, this method started running into issues…


The Command Doesn’t Work!

When I tried running this command again relying on my old records, I discovered that the Docker image hadn’t been updated in over 5 years. As a result, it wouldn’t work properly in the current environment.


Trying a New Approach

The key to obtaining a Let’s Encrypt certificate is being able to use Certbot. Therefore, I spun up a separate Docker container, installed Certbot inside it, and ran the following command:

certbot certonly --standalone -d {ドメイン名}

As a result, I was able to successfully obtain the certificate!


Applying the Certificate to the Web Server

After running the command, the certificate and private key are generated in the /etc/letsencrypt directory. I copied the contents of this directory to the web server and configured the web server’s configuration file to reference them.

With this, the certificate application was complete, and HTTPS connections became possible.


Conclusion

Let’s Encrypt is a remarkably convenient tool that you can use for free, but older methods may not keep up with changing environments, requiring you to seek out the latest approaches. Here are the key takeaways from this experience:

  1. Beware of using outdated Docker images
    • This time, issues arose due to an image that hadn’t been updated in over 5 years.
  2. Certbot is flexibly usable
    • As long as your Docker environment is set up, you can run Certbot using alternative containers.
  3. Certificate deployment and reference configuration are required
    • Properly applying the generated certificate to your web server completes the transition to HTTPS.

Let’s Encrypt provides free and reliable certificates—give it a try! Thank you for reading until the end ✨