How to create an SSL certificate with Let’s Encrypt

In this concise tutorial, I will cover how you can set up a trusted SSL certificate for free with Let’s Encrypt. SSL certificates are crucial for any website, because they encrypt data transmitted between the server and the user’s browser, helping ensu…


This content originally appeared on DEV Community and was authored by Brian W.

In this concise tutorial, I will cover how you can set up a trusted SSL certificate for free with Let’s Encrypt. SSL certificates are crucial for any website, because they encrypt data transmitted between the server and the user’s browser, helping ensure privacy and security. They also validate the website’s security, which can help your website gain trustworthiness.

First, launch your Linux terminal and run the following commands to install and run Certbot, which will allow us to generate a certificate:

sudo apt install snapd; # Only run if you don't have snapd installed
sudo snap install core; sudo snap refresh core; sudo snap install --classic certbot;

certbot certonly --manual;

Once you run the following commands, you will be asked to enter the domain name. Then, you will be prompted to verify your ownership of this domain by serving a file on your website. Follow the instructions to verify your website.

After you successfully verify your domain, Certbot will generate three different .pem files:

  • Private Key (privkey.pem): This file contains the private key, which is kept secret and is used to decrypt data that has been encrypted with the public key.
  • Certificate (cert.pem): This file contains the public key and other identifying information about your website and the Certificate Authority (CA).
  • Certificate Chain (chain.pem): This file contains the intermediate certificates that link your certificate back to the root certificate of the CA.

These files will likely be located in /etc/letsencrypt/live/yourdomain.com, unless otherwise stated by Certbot. You may now use the certificate for your website!

For example, you can use the following code to use your SSL certificates in Node.js:

const privateKey = fs.readFileSync('/etc/letsencrypt/live/yourdomain.com/privkey.pem', 'utf8');
const certificate = fs.readFileSync('/etc/letsencrypt/live/yourdomain.com/cert.pem', 'utf8');
const ca = fs.readFileSync('/etc/letsencrypt/live/yourdomain.com/chain.pem', 'utf8');

const server = https.createServer({ key: privateKey, cert: certificate, ca: ca }, app);
server.listen(443);

Congratulations, you have successfully issued your own SSL certificates for your website! If you found this guide helpful, or have any thoughts, let me know in the comments! Bye for now. 👋


This content originally appeared on DEV Community and was authored by Brian W.


Print Share Comment Cite Upload Translate Updates
APA

Brian W. | Sciencx (2024-06-26T00:42:17+00:00) How to create an SSL certificate with Let’s Encrypt. Retrieved from https://www.scien.cx/2024/06/26/how-to-create-an-ssl-certificate-with-lets-encrypt-2/

MLA
" » How to create an SSL certificate with Let’s Encrypt." Brian W. | Sciencx - Wednesday June 26, 2024, https://www.scien.cx/2024/06/26/how-to-create-an-ssl-certificate-with-lets-encrypt-2/
HARVARD
Brian W. | Sciencx Wednesday June 26, 2024 » How to create an SSL certificate with Let’s Encrypt., viewed ,<https://www.scien.cx/2024/06/26/how-to-create-an-ssl-certificate-with-lets-encrypt-2/>
VANCOUVER
Brian W. | Sciencx - » How to create an SSL certificate with Let’s Encrypt. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/06/26/how-to-create-an-ssl-certificate-with-lets-encrypt-2/
CHICAGO
" » How to create an SSL certificate with Let’s Encrypt." Brian W. | Sciencx - Accessed . https://www.scien.cx/2024/06/26/how-to-create-an-ssl-certificate-with-lets-encrypt-2/
IEEE
" » How to create an SSL certificate with Let’s Encrypt." Brian W. | Sciencx [Online]. Available: https://www.scien.cx/2024/06/26/how-to-create-an-ssl-certificate-with-lets-encrypt-2/. [Accessed: ]
rf:citation
» How to create an SSL certificate with Let’s Encrypt | Brian W. | Sciencx | https://www.scien.cx/2024/06/26/how-to-create-an-ssl-certificate-with-lets-encrypt-2/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.