Table of Contents

How to Create Self-Signed Certificates Using OpenSSL?

How to Create Self-Signed Certificates

In today’s tech-driven world, security has been my top priority. You will not believe it if you see the number of cybercrimes happening every day.

Our digital infrastructure, applications, and websites need to be safe and secure.

I believe that an SSL certificate is one of the most powerful tools in the security arsenal. You might be wondering about how to create self-signed certificates using OpenSSL.

One of the simplest and most cost-effective ways is by creating self-signed certificates right on your own systems.

Self-signed certificates are like my personal keys to secure my online assets. They are public-key certificates that you can generate yourself without needing to go through a certificate authority. 

I’m going to provide you with a tutorial on how to create self-signed certificates using OpenSSL on both Windows and Linux machines. 

Moreover, with assistance from the Linux Foundation resources, you can master this process with available discount codes, deals, and offers to get the best discounts on related materials.

So, let’s dive in and start securing your applications and infrastructure.

Discover the power of DreamHost with a risk-free trial! Experience top-notch hosting services with DreamHost free trial offer today.

What is a Self Signed Certificate?

Self Signed Certificates aka SSL certificates are a way to avoid approval from anyone else and use it as my own certificate authority. I get to sign my own certificate using my private key

Self Signed Certificate

I have always been associated with private networks, and that is where using self-signed certificates can be handy.

It is also needed during the early stages of creating software. But they also come with some risks if not handled carefully.

There are certain issues associated with self-signed certificates. Firstly there is a risk of losing track of how many I’ve created.

However, with the help of some dedicated sites to learn coding, it’s easier to learn how to handle certificates, even self-made ones.

Second, where I’ve put them, and lastly, who they belong to. It’s tough enough managing certificates from public and private authorities, but keeping tabs on self-signed ones is even harder.

It can get worse if my network gets hacked. I won’t have a clue if someone has messed with my self-signed certificate or its private key.

Unlike certificates from authorities, self-signed ones can’t be canceled. Not being able to quickly find and cancel the private key linked to a self-signed certificate is a serious risk.

How to Create Self-Signed Certificates using OpenSSL

The prerequisite for this process is to have OpenSSL installed to create self-signed certificates using OpenSSL,

  • For Linux: sudo apt-get install openssl
  • For MacOS: brew install openssl

Below, I am going to talk about how to create self-signed certificates using OpenSSL:

  1. Generate a root key for your new certificate authority:
openssl genrsa -out my_root_ca.key 2048
  1. Create a self-signed root certificate using the root key:
openssl req -x509 -new -nodes -key my_root_ca.key -sha256 -days 1825 -out my_root_ca.crt
  1. Generate a private key for your server:
openssl genrsa -out my_server.key 2048
  1. Create a certificate signing request (CSR) for your server. Be sure to set the Common Name to match the IP address or domain name where the certificate will be used:
openssl req -new -key my_server.key -out my_server.csr
  1. Sign the CSR with your root key and root certificate. If you’re creating a certificate for an IP address:
openssl x509 -req -extfile <(printf "subjectAltName=IP:127.0.0.1") -in my_server.csr -CA my_root_ca.crt -CAkey my_root_ca.key -CAcreateserial -out my_server.crt -days 365 -sha256
  1. Alternatively, if you’re creating a certificate for a domain name:
openssl x509 -req -extfile <(printf "subjectAltName=DNS:example.com") -in my_server.csr -CA my_root_ca.crt -CAkey my_root_ca.key -CAcreateserial -out my_server.crt -days 365 -sha256

These steps will guide you through creating a self-signed certificate authority and creating certificates for your server. It can be for both an IP address and a domain name.

How to Generate a Certificate Signing Request Using OpenSSL in Ubuntu?

Creating a self-signed certificate on Ubuntu can be a handy skill, especially if you want to secure your web server. Here’s how I did it:

  1. First thing first, I used an SSH client to connect to my Ubuntu VM.
  1. Then, I made sure I had all the latest package sources by running the “apt update” command.
sudo apt update 
  1. Third, I opened my web browser and visited my server’s IP address on port 80. This took me to the Apache homepage, but it was on the HTTP port. It is not secure. 
  2. Next, I started to install Prometheus kubernetes to make my server better at keeping track of things. Since Kubernetes needs good watching, adding Prometheus helps me check how well my Kubernetes groups are doing.
  3. To set up my certificates, I ran some commands. I created a directory called “~/certificates” and moved into that directory.
mkdir ~/certificates

cd ~/certificates
  1. The next step was to generate a Certificate Signing Request (CSR) and a private key using an OpenSSL command. When I ran this command, I had to enter some details as prompted.
openssl req -x509 -newkey rsa:4096 -keyout apache.key -out apache.crt -days 365 -nodes

This was the beginning of my journey to secure my web server with a self-signed certificate on Ubuntu.

I also took steps to monitor the Kubernetes cluster health. One integral aspect involved the process of downloading a new bridge CNI configuration to 11-crio-ipv4-bridge.conf.

It might sound a bit technical, but it’s a valuable skill to have in the world of web security.

Benefits of using a self-signed certificates

I am going to mention some of the benefits that I have had using a self-signed certificate: 

  1. It is quick and easy to create. 
  2. There is no cost associated with it.
  3. Useful for self-signed certificates while working on projects.
  4. Creating websites within my own network is easy.
  5. Personalize them with extra information.
  6. Use larger keys to make them more secure.
  7. I don’t have to depend on anyone else to get these certificates. 
  8. I can issue them myself, 
  9. Saves me a lot of time.
  10. Best while testing things out.

Disadvantage of Using a Self-signed Certificate

Based on my experience, I am going to tell you something about the disadvantages of using a self-signed certificate:

  1. Regular web browsers and operating systems don’t really trust self-signed certificates.
  2. They aren’t checked by big and trustworthy certificate authorities.
  3. No green lock symbol or other trust signs in my browser.
  4. Visitors to my website might see a warning like “error self-signed cert” or “err cert authority invalid.” 
  5. Warning signs are a big turn-off.
  6. Not good for my website traffic.
  7. Risky if the website deals with memberships or financial transactions.
  8. There’s also the danger of data theft and cyberattacks. 
  9. Prone to sneaky attacks like man-in-the-middle (MITM) schemes.

Conclusion

Hopefully, this guide on how to create self-signed certificates using OpenSSL has helped you enough.

We have talked about how to generate a self-signed certificate using OpenSSL and how to do the same in Ubuntu.

I have also mentioned some of the benefits and disadvantages of using these methods. Other than that, there are certain risks associated with this method. 

Frequently Asked Questions

Can I Create a .PEM Self-signed Certificate?

Yes, you can create a .PEM self-signed certificate. Follow the process mentioned below:
1) Remove the password from the Private Key: openssl rsa -in server.key -out nopassword.key
2) Now, you have to combine the private key, public certificate, and any 3rd party intermediate certificate files: cat nopassword.key > server.pem cat server.crt >> server.pem
3) Repeat this step as needed for third-party certificate chain files, bundles, etc: cat intermediate.crt >> server.pem

Can I Create My Own SSL Certificate?

Yes, you can create your own SSL certificate. All you have to do is to follow some simple steps. Please note that this method is not secure and it has its own risks with it. You will need to generate a public-private key pairing.

Ben Kelly

Ben Kelly

Ben Kelly is a hands-on cloud solution architect based in Florida with over 10 years of IT experience. He uses Ansible Technology to help innovative Automation DevOps, Cloud Engineers, System Administrators, and IT Professionals succeed in automating more tasks every day.

Leave a Reply

Your email address will not be published. Required fields are marked *