{"id":9963,"date":"2024-07-23T10:37:18","date_gmt":"2024-07-23T10:37:18","guid":{"rendered":"https:\/\/www.ssdnodes.com\/?p=9963"},"modified":"2025-05-15T15:30:03","modified_gmt":"2025-05-15T15:30:03","slug":"create-a-self-signed-certificate-on-ubuntu-for-apache-and-nginx","status":"publish","type":"post","link":"https:\/\/www.ssdnodes.com\/blog\/create-a-self-signed-certificate-on-ubuntu-for-apache-and-nginx\/","title":{"rendered":"How to Create a Self-Signed Certificate on Ubuntu 24.04 for Apache and Nginx"},"content":{"rendered":"<p>The last thing you want is to have your sensitive data hijacked because of bad web security practices. That's why you absolutely must create a self-signed certificate on your Ubuntu 24.04 VPS for your Apache or Nginx server.<\/p>\n<p>Securing your web traffic with SSL\/TLS encryption to handle <a href=\"https:\/\/www.ssdnodes.com\/blog\/an-introduction-to-the-http-protocol-and-its-role-in-the-web\/\">HTTPS<\/a> communications is an essential part of building any public or private web service, because without it, your web service will have weak privacy and insecure data transfer, and users won\u2019t trust your services.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10219 size-full aligncenter\" src=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/07\/1-2.jpg\" alt=\"Create a Self-Signed Certificate on Ubuntu 24.04 for Apache and Nginx\" width=\"579\" height=\"386\" srcset=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/07\/1-2.jpg 579w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/07\/1-2-300x200.jpg 300w\" sizes=\"auto, (max-width: 579px) 100vw, 579px\" \/><\/p>\n<h2>Why Create a Self-Signed Certificate on Ubuntu?<\/h2>\n<p>Once you create a self-signed certificate on Ubuntu, SSL\/TLS encryption will protect your data transfer and prevent sensitive data exposure, in addition to ensuring that the connection is between the correct entities by cryptographically verifying that you\u2019re connecting with an authentic server, and that the messages have not been interfered with while being transferred.<\/p>\n<p><strong>Note:<\/strong> From now on we will refer to SSL\/TLS certificates as simply \"SSL certificates\" for brevity.<\/p>\n<h2>How to Create a Self-Signed Certificate on Ubuntu<\/h2>\n<p>To create a self-signed certificate on Ubuntu, you'll need to use OpenSSL to generate a private key and a self-signed certificate, specifying the required details like the certificate's validity period and your organization's information. Next, you'll save the key and certificate files in a secure location, and then use it in your Apache or Nginx server configuration.<\/p>\n<h3>(Special Offer) - Simplify Your SSL Setup with Our 1-Click VPS Applications<\/h3>\n<blockquote><p>If generating a self-signed SSL certificate sounds daunting, we've got you covered. Our <a href=\"https:\/\/ssdnodes.com\/\" target=\"_blank\" rel=\"noopener\">1-Click VPS applications<\/a> (<a href=\"https:\/\/www.ssdnodes.com\/blog\/how-to-install-wordpress-with-lemp-and-mariadb-on-ubuntu\/\">WordPress<\/a>, <a href=\"https:\/\/www.ssdnodes.com\/blog\/how-to-install-mysql-and-phpmyadmin-on-debian-11\/\">phpMyAdmin<\/a>, <a href=\"https:\/\/www.ssdnodes.com\/blog\/installing-lamp-on-ubuntu-22-04-lts-jammy-jellyfish\/\">LAMP<\/a>, and <a href=\"https:\/\/www.ssdnodes.com\/blog\/installing-lemp-on-ubuntu-22-04-lts-jammy-jellyfish\/\">LEMP<\/a>, and many others) come with a pre-installed self-signed SSL certificate. Just a few clicks and you're ready to go! Visit <a href=\"https:\/\/ssdnodes.com\/\" target=\"_blank\" rel=\"noopener\">our website<\/a> to get started with the lowest-cost VPS offerings in the world (self-signed certificates included)!<\/p><\/blockquote>\n<h2>Step 1 - Using OpenSSL to Generate a Self-Signed Certificate<\/h2>\n<p>To create a self-signed certificate on Ubuntu, you will use OpenSSL to generate a certificate file that will store some basic information about your site, accompanied by an SSL private key file that will be kept secret in the server, and the server then will use it to securely handle encrypted data.<\/p>\n<p>OpenSSL is a software library that provides tools for general-purpose cryptography and secure communications.<\/p>\n<p>The private SSL key is used by the server to encrypt the content it sends to clients (e.g., web browser) The public SSL certificate is shared publicly with clients requesting the content. So when you request a page, the browser gets the SSL certificate from the server, and uses it to decrypt and access the content signed by the associated private SSL key.<\/p>\n<p>The first step to obtaining an SSL certificate is using OpenSSL to create a certificate signing request (CSR). In normal cases, the CSR will be sent to the Certificate Authority (CA) which in turn will create a certificate based on it. In our case (self-signed certificate), we will create the certificate ourselves based on this CSR we generate using OpenSSL. The CSR contains the common name(s) you want your certificate to secure, information about your company, and your public key.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-10223 size-full\" src=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/07\/How-to-Create-a-Self-Signed-Certificate.png\" alt=\"Create a self-signed certificate on Ubuntu\" width=\"579\" height=\"386\" srcset=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/07\/How-to-Create-a-Self-Signed-Certificate.png 579w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/07\/How-to-Create-a-Self-Signed-Certificate-300x200.png 300w\" sizes=\"auto, (max-width: 579px) 100vw, 579px\" \/><\/p>\n<p><strong>Note:<\/strong> In order for a CSR to be created, it needs to have a private key from which the public key is extracted. This can be done by using an existing private key or generating a new private key. It is strongly recommended to generate a new private key when creating a CSR instead of using an existing one.<\/p>\n<p>To create a certificate signing request (CSR) and a private key with the <code>openssl<\/code> library, you will use the <code>openssl req<\/code> command with the following command structure:<\/p>\n<pre><code>openssl req -x509 -newkey rsa:&lt;rsa_value&gt; -nodes -out &lt;public certificate path&gt; -keyout &lt;private key path&gt; -days &lt;certificate duration in days&gt; -subj \"C=&lt;country code&gt;\/O=&lt;organization name&gt;\/OU=&lt;organizational unit&gt;\/CN=&lt;common name&gt;\"<\/code><\/pre>\n<p>Here is what each part of the preceding command means:<\/p>\n<ul>\n<li><code>-x509<\/code>: A multi-purpose certificate utility. It can be used to display certificate information, convert certificates to various forms, sign certificate requests like a \"mini CA\" or edit certificate trust settings.<\/li>\n<li><code>-newkey<\/code>: Specifies that a new private key should be created with the certificate request.<\/li>\n<li><code>-rsa:<\/code>: The encryption algorithm you\u2019ll use to generate your key. While you can use other encryption algorithms if you want, RSA is one of the best encryption systems that you can use to protect your data in transmission, especially because it comes with great compatibility. <code>&lt;rsa_value&gt;<\/code>\u00a0represents the key size in bits.<\/li>\n<li><code>-nodes<\/code>: is not the English word \"nodes\", it refers, instead, to \"no DES\". When given as an argument, it means OpenSSL will not encrypt the private key in a PKCS#12 file, and the private key will not have a passphrase. This is important for the web server to have access to the certificate file without needing a passphrase. Otherwise the server would wait for the user to manually enter the passphrase every time the server restarts, which is not convenient.<\/li>\n<li><code>-out<\/code>: defines the path the public key will be generated to, including the filename.<\/li>\n<li><code>-keyout<\/code>: defines the path the private key will be generated to, including the filename.<\/li>\n<li><code>-days<\/code>: The certificate\u2019s lifetime in days.<\/li>\n<li><code>-subj<\/code>: is used to provide all the necessary information within the command itself, instead of having to provide each required piece of information via command line prompts.\n<ul>\n<li><code>C<\/code> defines the two-letter country code where your company is legally located.<\/li>\n<li><code>O<\/code> defines the organization\u2019s name.<\/li>\n<li><code>OU<\/code> defines the organizational unit name, which can be the name of your department within the organization.<\/li>\n<li><code>CN<\/code> is the common name, where you either enter the fully-qualified domain name (FQDN) you\u2019ll use to access the server by (e.g., www.example.com), or the public IP of the server.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Now that you are familiar with the <code>openssl<\/code> command options and actions, you can form and execute an <code>openssl<\/code> command to generate a certificate signing request (CSR) as follows:<\/p>\n<pre><code>sudo openssl req -x509 -newkey rsa:4096 -nodes -out \/etc\/ssl\/certs\/ssl-selfsigned.pem -keyout \/etc\/ssl\/private\/ssl-selfsigned.key -days 365 -subj \"\/C=US\/O=MyCompany\/OU=Technical Department\/CN=www.example.com\"<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-9979\" src=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/06\/openssl-output.webp\" alt=\"OpenSSL generate a self-signed certificate output\" width=\"600\" height=\"387\" srcset=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/06\/openssl-output.webp 700w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/06\/openssl-output-300x194.webp 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><br \/>\nThis command will generate two files automatically created under the respective subdirectories you\u2019ve declared:<\/p>\n<ul>\n<li><code>\/etc\/ssl\/private\/<\/code>: will be the location of the SSL private key file.<\/li>\n<li><code>\/etc\/ssl\/certs\/<\/code>: will be the location of your CSR file.<\/li>\n<\/ul>\n<p>In our example, this means that the following files will be generated:<\/p>\n<ul>\n<li><code>\/etc\/ssl\/private\/ssl-selfsigned.key<\/code>: your SSL private key file.<\/li>\n<li><code>\/etc\/ssl\/certs\/ssl-selfsigned.pem<\/code>: your CSR file, which you can use as a self-signed certificate.<\/li>\n<\/ul>\n<h2>Step 2 - Configuring Apache and Nginx to Use a Self-Signed Certificate<\/h2>\n<p>Now that you have your very own self-signed SSL certificate in the form of a CSR file, you can use it to encrypt your data and serve HTTPS requests. To do so, you need to configure your web server to use it. In this step, you\u2019ll learn how to configure and use your self-signed SSL certificate on the two most popular HTTP web servers: Apache, and Nginx.<\/p>\n<h3>Creating a Self-Signed SSL Certificate For Apache on Ubuntu<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10225 size-full aligncenter\" src=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/07\/3-1.jpg\" alt=\"Self-Signed SSL Certificate For Apache on Ubuntu\" width=\"579\" height=\"386\" srcset=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/07\/3-1.jpg 579w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/07\/3-1-300x200.jpg 300w\" sizes=\"auto, (max-width: 579px) 100vw, 579px\" \/><\/p>\n<p>In this section, you\u2019ll learn how to configure the Apache web server to use your self-signed SSL certificate.<\/p>\n<p>First, open Apache\u2019s default configuration file:<\/p>\n<pre><code>sudo nano \/etc\/apache2\/sites-enabled\/000-default.conf<\/code><\/pre>\n<p>By default, your Apache welcome page loads on port 80 without an SSL certificate.<\/p>\n<p>Your Apache\u2019s default configuration will be similar to the following:<\/p>\n<pre><code>&lt;VirtualHost *:80&gt;\r\n        Define servername <mark>www.example.com<\/mark>\r\n        ServerName ${SERVERNAME}\r\n        ServerAdmin webmaster@localhost\r\n        DocumentRoot \/var\/www\/html\r\n&lt;\/VirtualHost&gt;<\/code><\/pre>\n<p>Replace the existing content with the following configuration, and make sure to set the correct values where needed (highlighted in <mark>yellow<\/mark> below):<\/p>\n<pre><code>&lt;VirtualHost *:80&gt;\r\n        Define servername <mark>www.example.com<\/mark>\r\n        ServerName ${SERVERNAME}\r\n        RewriteEngine on\r\n        RewriteRule ^\/.*$ https:\/\/\\${SERVERNAME}%{SCRIPT_FILENAME}?%{QUERY_STRING} [R=301]\r\n        ErrorLog ${APACHE_LOG_DIR}\/error.log\r\n        CustomLog ${APACHE_LOG_DIR}\/access.log combined\r\n&lt;\/VirtualHost&gt;\r\n&lt;VirtualHost *:443&gt;\r\n        SSLEngine On\r\n        SSLCertificateFile <mark>\/etc\/ssl\/certs\/ssl-selfsigned.pem<\/mark>\r\n        SSLCertificateKeyFile <mark>\/etc\/ssl\/private\/ssl-selfsigned.key<\/mark>\r\n        ServerName ${SERVERNAME}\r\n        DocumentRoot \/var\/www\/html\r\n        ErrorLog ${APACHE_LOG_DIR}\/error.log\r\n        CustomLog ${APACHE_LOG_DIR}\/access.log combined\r\n&lt;\/VirtualHost&gt;<\/code><\/pre>\n<p>Here you add two configurations, one for HTTP connections on port 80, and one for HTTPS on port 443.<\/p>\n<p>In the HTTP configuration, you use the <code>RewriteEngine<\/code> and <code>RewriteRule<\/code> to redirect HTTP requests to HTTPS. And you also set locations for log files.<\/p>\n<p>In the Apache SSL virtual host example configuration above, you set the <code>SSLEngine<\/code> directive to <code>On<\/code> to enable the SSL\/TLS Protocol Engine. You set the paths of the self-signed SSL certificate and the SSL private key files you generated earlier. You declare the server name, and the document root directory that holds the files Apache serves. And you also set locations for log files.<\/p>\n<p>Next, use the <code>a2enmod<\/code> tool to enable the <code>SSL<\/code> and the <code>RewriteEngine<\/code> Apache modules. This allows Apache to use SSL\/TLS encryption, and the <code>RewriteEngine<\/code> feature to rewrite requested URLs and redirect users from HTTP to HTTPS:<\/p>\n<pre><code>sudo a2enmod ssl rewrite<\/code><\/pre>\n<p>Next, test for configuration errors:<\/p>\n<pre><code>sudo apache2ctl configtest<\/code><\/pre>\n<p>You should receive an output that contains the text <code>Syntax OK<\/code>, which means you can safely reload Apache, otherwise, you will get a very specific description pointing out the error you have to fix.<\/p>\n<p>Next, restart Apache:<\/p>\n<pre><code>sudo systemctl restart apache2\r\n<\/code><\/pre>\n<p>Now visit your website\u2019s domain name or IP address using <code>https:\/\/<\/code> at the beginning:<\/p>\n<pre><code>https:\/\/domain_name_or_IP<\/code><\/pre>\n<p>You should see an error telling you that the website is not secure. This means that the self-signed certificate is properly installed, but because the browser does not recognize your certificate as valid, you\u2019ll receive this error. As we\u2019ve mentioned earlier, this self-signed certificate is only for testing purposes and internal use, and not to secure your website for production, because your certificate is not signed by any of the browser\u2019s known certificate authorities. To install a certificate that browsers trust check out this article.<\/p>\n<p>Now that you\u2019ve learned how to configure Apache to use a self-signed certificate, you\u2019ll see how to do the same with an Nginx server.<\/p>\n<h3>Creating a Self-Signed SSL Certificate For Nginx on Ubuntu<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-10227 size-full\" src=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/07\/4.jpg\" alt=\"configuring a self signed ssl certificate for nginx\" width=\"579\" height=\"386\" srcset=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/07\/4.jpg 579w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/07\/4-300x200.jpg 300w\" sizes=\"auto, (max-width: 579px) 100vw, 579px\" \/><\/p>\n<p>In this section, you\u2019ll learn how to configure the Nginx web server to use your self-signed SSL certificate.<\/p>\n<p>First, open Nginx's default configuration file:<\/p>\n<pre><code>sudo nano \/etc\/nginx\/sites-enabled\/default<\/code><\/pre>\n<p>By default, your Nginx welcome page loads on port 80 without an SSL certificate. So, you would see something similar to the following configuration:<\/p>\n<pre><code>server {\r\n        listen 80;\r\n        listen [::]:80;\r\n        root \/var\/www\/html;\r\n\r\n        index index.html index.htm index.nginx-debian.html;\r\n\r\n        server_name <mark>www.example.com;<\/mark>\r\n        location \/ {\r\n                    try_files $uri $uri\/ =404;\r\n        }\r\n}<\/code><\/pre>\n<p>Replace the existing content with the following configuration, and make sure to set the correct values where needed (highlighted in <mark>yellow<\/mark> below):<\/p>\n<pre><code>server {\r\n    listen 80;\r\n    listen [::]:80;\r\n    server_name <mark>www.example.com<\/mark>;\r\n    access_log off;\r\n    location \/ {\r\n        rewrite ^ https:\/\/$host$request_uri? permanent;\r\n    }\r\n}\r\n\r\nserver {\r\n    listen 443 ssl;\r\n    listen [::]:443 ssl;\r\n    server_name <mark>www.example.com<\/mark>;\r\n    root <mark>\/var\/www\/html<\/mark>;\r\n    index index.php index.html index.htm index.nginx-debian.html;\r\n    autoindex off;\r\n    ssl_certificate <mark>\/etc\/ssl\/certs\/ssl-selfsigned.pem<\/mark>;\r\n    ssl_certificate_key <mark>\/etc\/ssl\/private\/ssl-selfsigned.key<\/mark>;\r\n    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;\r\n    ssl_ciphers HIGH:!aNULL:!MD5;\r\n\r\n    location ~ \\.php$ {\r\n         include snippets\/fastcgi-php.conf;\r\n         fastcgi_pass unix:\/var\/run\/php\/php-fpm.sock;\r\n         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\r\n         include fastcgi_params;\r\n    }\r\n}<\/code><\/pre>\n<p>Here, you have two <em>server blocks<\/em> representing configuration for two ports: port <code>80<\/code> which serves HTTP requests, and port <code>443<\/code> that serves HTTPS requests.<\/p>\n<p>Notice that, in the HTTP configuration, you use the <code>rewrite<\/code> directive in the <code>location<\/code> block to redirect HTTP requests to HTTPS.<\/p>\n<p>In the HTTPS configuration, you set up Nginx to use SSL and set the path of the self-signed SSL certificate file and the SSL private key file you generated earlier. In the <code> location ~ \\.php$<\/code>, you set up Nginx to process PHP files with the <code>php-fpm<\/code> package.<\/p>\n<p>With the configuration file modified, check for syntax errors in it using the following command:<\/p>\n<pre><code>sudo nginx -t<\/code><\/pre>\n<p>The output should let you know that the configuration file test is successful.<br \/>\nNow, restart Nginx:<\/p>\n<pre><code>sudo systemctl restart nginx<\/code><\/pre>\n<p>Now visit your website\u2019s domain name or IP address using <code>https:\/\/<\/code> at the beginning:<\/p>\n<pre><code>https:\/\/domain_name_or_IP<\/code><\/pre>\n<p>Again, you should see an error telling you that the website is not secure, as this self-signed certificate is only for testing purposes and internal use, and not to secure your website for production, because your certificate is not signed by any of the browser\u2019s known certificate authorities. Again, to install a certificate that browsers trust check out this article.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-10231 size-full\" src=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/07\/How-to-Create-a-Self-Signed-Certificate-1.png\" alt=\"verifying self-signed certificates for Apache and Nginx\" width=\"579\" height=\"386\" srcset=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/07\/How-to-Create-a-Self-Signed-Certificate-1.png 579w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/07\/How-to-Create-a-Self-Signed-Certificate-1-300x200.png 300w\" sizes=\"auto, (max-width: 579px) 100vw, 579px\" \/><\/p>\n<h2>Step 3 - Verify That Your Self-Signed SSL Certificate Works<\/h2>\n<p>Before you verify that your self-signed SSL certificate works, please check the following:<\/p>\n<ul>\n<li>In the configuration files of both Apache and Nginx, remember to set the server name value to whatever you intend to address your server with. This can be a hostname, full domain name, or an IP address, and make sure it matches the <strong>Common Name<\/strong> you chose when creating the certificate. In Apache, the server name is configured using the <code>ServerName<\/code> directive, and in Nginx, it\u2019s the <code>server_name<\/code> directive.<\/li>\n<li>The document root is the root directory you serve your web files from. It is configured using the <code>DocumentRoot<\/code> directive in Apache, and the <code>root<\/code> directive in Nginx.<\/li>\n<li>The redirection configurations we\u2019ve added introduce the good practice of responding on port 80, even if you want to force all traffic to be encrypted. Whenever a user requests a page using an HTTP request, they will be automatically redirected to the HTTPS equivalent of the URL they\u2019ve requested. You can test this new redirect functionality by visiting your site with plain <code>http:\/\/<\/code>and you\u2019ll notice that you will be automatically redirected to a URL beginning with <code>https:\/\/<\/code>.<\/li>\n<li>If you visit your site in a browser, prefixing <code>https:\/\/<\/code> to the URL, you would get an error, explaining that your website is not secure as mentioned above. This means that the browser can\u2019t verify the identity of the server, since the certificate is not signed by any of its known certificate authorities. However, this is completely normal for a self-signed certificate and actually means that your SSL configuration <em>is successful<\/em>.<\/li>\n<\/ul>\n<p>On receiving the browser error that tells you that the connection is not secure, click the <strong>Advanced<\/strong> button or <strong>More information<\/strong> depending on the browser, and choose to proceed. The following is an example of the error in the Google Chrome browser:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-9980\" src=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/06\/Privacy-Error-1024x470.png\" alt=\"Create an nginx self signed certificate\" width=\"700\" height=\"321\" srcset=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/06\/Privacy-Error-1024x470.png 1024w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/06\/Privacy-Error-300x138.png 300w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/06\/Privacy-Error-768x352.png 768w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/06\/Privacy-Error.png 1110w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-9981\" src=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/06\/Proceed.webp\" alt=\"Create an Apache self signed certificate\" width=\"700\" height=\"537\" srcset=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/06\/Proceed.webp 934w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/06\/Proceed-300x230.webp 300w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/06\/Proceed-768x590.webp 768w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/p>\n<p>Once you proceed, your browser will load the Apache or Nginx welcome page, but with a noticeable danger icon and a <strong>Not Secure<\/strong> label at the beginning of your URL.<\/p>\n<p>If you click the danger icon, the browser will inform you that the certificate is not valid:<\/p>\n<h3>A Self-Signed SSL Certificate with Apache (Example)<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9982\" src=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/06\/Info-0.png\" alt=\"ubuntu apache ssl\" width=\"320\" height=\"410\" srcset=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/06\/Info-0.png 320w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/06\/Info-0-234x300.png 234w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><\/p>\n<p>Here is the Apache welcome page with a self-signed SSL certificate:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-9985\" src=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/06\/Welcome.webp\" alt=\"Apache self signed certificate welcome page\" width=\"600\" height=\"470\" srcset=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/06\/Welcome.webp 929w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/06\/Welcome-300x235.webp 300w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/06\/Welcome-768x602.webp 768w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3>A Self-Signed SSL Certificate with Nginx (Example)<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2022\/06\/Securing-your-site-with-Self-Signed-or-CA-certificates_06-e1656578767657.png\" alt=\" nginx self signed certificate welcome page\" width=\"778\" height=\"361\" \/><\/p>\n<p>In the pop-ups above, click on <strong>\u201cCertificate is not valid\u201d<\/strong> for more details on the self-signed certificate. (Note the 1-year duration, we\u2019ve declared using the <code>days<\/code> value on the certificate\u2019s creation).<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9983\" src=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/06\/InfoFull.webp\" alt=\"self-signed ssl certificate info: nginx &amp; apache\" width=\"549\" height=\"674\" srcset=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/06\/InfoFull.webp 549w, https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/06\/InfoFull-244x300.webp 244w\" sizes=\"auto, (max-width: 549px) 100vw, 549px\" \/><\/p>\n<p>Although this sounds like something has gone wrong, don't worry! This is how you verify that the self-signed certificate is successfully installed!<\/p>\n<p>To avoid this error and install a trusted certificate check out<strong> this article<\/strong>.<\/p>\n<h2>Congrats!<\/h2>\n<p>Your website has become certified with a self-signed certificate, and you can now securely transfer data through <a href=\"https:\/\/www.ssdnodes.com\/blog\/an-introduction-to-the-http-protocol-and-its-role-in-the-web\/\">HTTPS<\/a>, and protect your <em>internal<\/em> traffic.<\/p>\n<h3>Facing Difficulties? - Simplify Your SSL Setup with Our 1-Click VPS Applications<\/h3>\n<blockquote><p>If generating a self-signed SSL certificate sounds too complex, we've got you covered. Our <a href=\"https:\/\/ssdnodes.com\/\" target=\"_blank\" rel=\"noopener\">1-Click VPS applications<\/a> (<a href=\"https:\/\/www.ssdnodes.com\/blog\/how-to-install-wordpress-with-lemp-and-mariadb-on-ubuntu\/\">WordPress<\/a>, <a href=\"https:\/\/www.ssdnodes.com\/blog\/how-to-install-mysql-and-phpmyadmin-on-debian-11\/\">phpMyAdmin<\/a>, <a href=\"https:\/\/www.ssdnodes.com\/blog\/installing-lamp-on-ubuntu-22-04-lts-jammy-jellyfish\/\">LAMP<\/a>, and <a href=\"https:\/\/www.ssdnodes.com\/blog\/installing-lemp-on-ubuntu-22-04-lts-jammy-jellyfish\/\">LEMP<\/a>, and many others) come with a pre-installed self-signed SSL certificate. Just a few clicks and you're ready to go! Visit <a href=\"https:\/\/ssdnodes.com\/\" target=\"_blank\" rel=\"noopener\">our website<\/a> to get started with the lowest-cost VPS offerings in the world (self-signed certificates included)!<\/p><\/blockquote>\n<h2>FAQ: Creating a Self-Signed Certificate on Ubuntu for Apache and Nginx<\/h2>\n<h3>How to Renew a Self-Signed Certificate?<\/h3>\n<p>To renew a self-signed certificate, generate a new certificate with updated validity. For Apache or Nginx on Ubuntu, use OpenSSL to create a new key and certificate.<\/p>\n<p>Update the configuration files of your web server to use the new certificate and restart the server to apply the changes.<\/p>\n<h3>How to Remove a Self-Signed Certificate?<\/h3>\n<p>To remove a self-signed certificate, delete the certificate and key files from your server, then\u00a0update your web server's configuration files to remove references to the deleted certificate and restart the server.<\/p>\n<h3>Firefox: The Certificate is Not Trusted Because it is Self-Signed<\/h3>\n<p>Firefox does not trust self-signed certificates by default because they are not issued by a recognized Certificate Authority (CA). To bypass this, you can manually add the self-signed certificate to Firefox's trusted certificates:<\/p>\n<ol>\n<li>Visit the site with the self-signed certificate in Firefox.<\/li>\n<li>Click on the warning icon in the address bar.<\/li>\n<li>Click \"Advanced\" and then \"Accept the Risk and Continue.\"<\/li>\n<\/ol>\n<div class=\"flex-shrink-0 flex flex-col relative items-end\">\n<div>\n<div class=\"pt-0.5 juice:pt-0\"><\/div>\n<\/div>\n<\/div>\n<div class=\"group\/conversation-turn relative flex w-full min-w-0 flex-col agent-turn\">\n<div class=\"flex-col gap-1 md:gap-3\">\n<div class=\"flex flex-grow flex-col max-w-full\">\n<div class=\"min-h-[20px] text-message flex flex-col items-start whitespace-pre-wrap break-words [.text-message+&amp;]:mt-5 juice:w-full juice:items-end overflow-x-auto gap-2\" dir=\"auto\" data-message-author-role=\"assistant\" data-message-id=\"4679a4d8-6849-4776-b55d-e199f4076d14\">\n<div class=\"flex w-full flex-col gap-1 juice:empty:hidden juice:first:pt-[3px]\">\n<div class=\"markdown prose w-full break-words dark:prose-invert light\">\n<h3>Self-Signed vs CA Certificates<\/h3>\n<p>Self-signed certificates and CA (Certificate Authority) certificates both provide encryption for your website, but they differ significantly in terms of trust and validation.<\/p>\n<h4>Self-Signed Certificates:<\/h4>\n<ul>\n<li><strong>Trust:<\/strong> Not trusted by browsers, causing security warnings.<\/li>\n<li><strong>Cost:<\/strong> Free.<\/li>\n<li><strong>Use Case:<\/strong> Internal testing and development.<\/li>\n<\/ul>\n<h4>CA Certificates:<\/h4>\n<ul>\n<li><strong>Trust:<\/strong> Trusted by browsers, no security warnings.<\/li>\n<li><strong>Cost:<\/strong> Free or paid.<\/li>\n<li><strong>Use Case:<\/strong> Public websites and production-ready web applications.<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Secure your Ubuntu 24.04 server with a self-signed SSL certificate for Apache or Nginx. Follow our guide to generate and configure SSL for encrypted traffic.<\/p>\n","protected":false},"author":15,"featured_media":10212,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[18,30],"tags":[202,200,201,185],"class_list":["post-9963","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops","category-tutorials","tag-ca-ssl","tag-https","tag-self-signed-ssl","tag-ubuntu"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/posts\/9963","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/comments?post=9963"}],"version-history":[{"count":41,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/posts\/9963\/revisions"}],"predecessor-version":[{"id":12919,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/posts\/9963\/revisions\/12919"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/media\/10212"}],"wp:attachment":[{"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/media?parent=9963"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/categories?post=9963"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/tags?post=9963"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}