<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Paula</title>
    <description>The latest articles on DEV Community by Paula (@pauladj).</description>
    <link>https://dev.to/pauladj</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F916567%2F02fb5e31-15e1-4c2f-89f0-36ad9486de09.jpg</url>
      <title>DEV Community: Paula</title>
      <link>https://dev.to/pauladj</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pauladj"/>
    <language>en</language>
    <item>
      <title>How to deploy a MySQL server using docker containers</title>
      <dc:creator>Paula</dc:creator>
      <pubDate>Mon, 27 Mar 2023 11:45:10 +0000</pubDate>
      <link>https://dev.to/pauladj/how-to-deploy-a-mysql-server-using-docker-containers-1pn0</link>
      <guid>https://dev.to/pauladj/how-to-deploy-a-mysql-server-using-docker-containers-1pn0</guid>
      <description>&lt;p&gt;Docker has revolutioned the way we deploy and manage applications. One common use case is running databases like MySQL in Docker containers for development, testing, or even production environments.&lt;/p&gt;

&lt;p&gt;This article aims to explain how to deploy and configure a MySQL server using docker containers.&lt;/p&gt;

&lt;p&gt;We will go step by step, and at the end of this blog, you will be able to access your MySQL server using a MySQL client, such as HeidiSQL.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why containers?
&lt;/h2&gt;

&lt;p&gt;Imagine you are working on multiple projects with different needs. One of them needs a MySQL 8.0.32 and the other the version 5.7. How would you go about it?&lt;/p&gt;

&lt;p&gt;Maybe your first thought is to install them locally or to use XAMPP, but for starters, you would need to change the default port. &lt;/p&gt;

&lt;p&gt;And if you want to have two separate MySQL with the same version?&lt;/p&gt;

&lt;p&gt;Things can get complicated quickly.&lt;/p&gt;

&lt;p&gt;With containers though, it’s easy. You specify the version and you are done.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install Docker
&lt;/h2&gt;

&lt;p&gt;If you haven’t already, start by installing Docker on your system. You can download Docker Desktop for Windows and macOS or Docker Engine for Linux from the official Docker website.&lt;/p&gt;

&lt;p&gt;It’s also available for the new M1/M2 macOS with the arm64 architecture.&lt;/p&gt;

&lt;h2&gt;
  
  
  Docker image
&lt;/h2&gt;

&lt;p&gt;The first step is to find the MySQL base image we want to use. DockerHub is a good place to start. If you type "mysql" in the search bar you can choose the image you want, "mysql" or "mariadb" from the results.&lt;/p&gt;

&lt;p&gt;In this case, we are choosing &lt;code&gt;mysql:8.0&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The link to the image: &lt;a href="https://hub.docker.com/_/mysql"&gt;https://hub.docker.com/_/mysql&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Docker compose
&lt;/h2&gt;

&lt;p&gt;We could execute a &lt;code&gt;docker run&lt;/code&gt; and start the container quickly. If we want to change and restart its configuration it’s easier to use a &lt;code&gt;docker-compose.yml&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: "3.9"
services:
  database:
    container_name: "database"
    image: mysql:8.0
    environment:
      - MYSQL_ROOT_PASSWORD=dummy_pass
    volumes:
      - db-data:/var/lib/mysql
    ports:
      - "3306:3306"
volumes:
  db-data:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can find all the possible environment variables on &lt;a href="https://hub.docker.com/_/mysql"&gt;the docker image page&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The next step is to execute the following command:&lt;br&gt;
&lt;code&gt;docker-compose up -d&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After that, we can connect to the MySQL container using a MySQL client like HeidiSQL.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hp9DKkAA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qns85ztjvd310giekk3e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hp9DKkAA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qns85ztjvd310giekk3e.png" alt="Image description" width="554" height="525"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can access the mysql server from the terminal too. For example:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker exec -it database /bin/bash -c "mysql -uroot -pdummy_pass"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mZ0BtFcw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bav1rrt810rz801movrz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mZ0BtFcw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bav1rrt810rz801movrz.png" alt="Image description" width="800" height="294"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Persist data
&lt;/h2&gt;

&lt;p&gt;By default, Docker containers are ephemeral, meaning data is lost when the container stops. To persist your MySQL data, you can use Docker volumes. &lt;br&gt;
For example, in the docker-compose example we have &lt;code&gt;db-data:/var/lib/mysql&lt;/code&gt;. That is a docker volume.&lt;/p&gt;




&lt;p&gt;Running MySQL in Docker containers provides flexibility and isolation for your database environment. It’s a convenient way to manage MySQL for various use cases, from development to production.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>mysql</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to configure a static IP address on CentOS 7 with VirtualBox</title>
      <dc:creator>Paula</dc:creator>
      <pubDate>Mon, 27 Mar 2023 08:53:26 +0000</pubDate>
      <link>https://dev.to/pauladj/how-to-configure-a-static-ip-address-on-centos-7-with-virtualbox-3dhj</link>
      <guid>https://dev.to/pauladj/how-to-configure-a-static-ip-address-on-centos-7-with-virtualbox-3dhj</guid>
      <description>&lt;p&gt;This article aims to explain how to configure a static IP address on a CentOS 7 virtual machine using VirtualBox.&lt;/p&gt;

&lt;p&gt;We will go step by step, and at the end of this blog, you will be able to ssh into your virtual machine using a never-changing IP.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a static IP?
&lt;/h2&gt;

&lt;p&gt;Every computer has a random local IP address unless you have specified the contrary. These addresses are not fixed. It means that they could change.&lt;/p&gt;

&lt;p&gt;In most cases, you don’t care about the IP address, but you usually do with virtual machines.&lt;/p&gt;

&lt;p&gt;If you have a MySQL service running on a virtual machine, you would want to save the connection configuration once and re-use it every time. If the IP address changes, you have to modify the connection settings.&lt;/p&gt;

&lt;p&gt;Another approach is to use port-forwarding. This approach is okay until you have 3 or more virtual machines with multiple services and ports to keep track of.&lt;/p&gt;

&lt;p&gt;The following image shows the ideal local development environment with static IP addresses.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fahu04972pqpyjlavwqky.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fahu04972pqpyjlavwqky.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Configure VirtualBox Networking
&lt;/h2&gt;

&lt;p&gt;The app VirtualBox has some networking settings we have to set before changing the VM Linux configuration.&lt;/p&gt;

&lt;p&gt;We want our VM to have the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Access to the internet&lt;/li&gt;
&lt;li&gt;Access to our host computer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And we also want to be able to access the VM by IP.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Stop the VM
&lt;/h3&gt;

&lt;p&gt;You have to stop the VM before doing the following steps.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Create Ethernet Adapter
&lt;/h3&gt;

&lt;p&gt;Click on Tools - Networks and make sure you have an ethernet adapter created. Write down the IPv4 Prefix, because the static IP will be in this range.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8oyc6ffvvuh602ax8diq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8oyc6ffvvuh602ax8diq.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the image above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The gateway is 192.168.56.1 &lt;/li&gt;
&lt;li&gt;The network mask is 255.255.255.0 (24 bits)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The static IP of my VM will be in the 192.168.56.xx range.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Change adapters
&lt;/h3&gt;

&lt;p&gt;Right-click on the virtual machine and choose the “Network” tab.&lt;br&gt;
We are going to add 2 adapters:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The first one is going to be a NAT. This way the VM will have internet access.&lt;/li&gt;
&lt;li&gt;The second one has to be a “Host-only Adapter” with the ethernet adapter of the previous step. This is the adapter that will have the static IP assigned.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvdp3p5x88y5d4es10mmp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvdp3p5x88y5d4es10mmp.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Configure VM Centos 7
&lt;/h2&gt;

&lt;p&gt;Now that we have configured the VirtualBox networking, we will configure the inner VM networking settings.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 1: Start the VM
&lt;/h3&gt;

&lt;p&gt;Double-click on the VM or right-click and start.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 2: Get the connection name
&lt;/h3&gt;

&lt;p&gt;We know the static IP will be assigned to the second adapter, the Host-only Adapter. &lt;/p&gt;

&lt;p&gt;Let’s check the vm networking using &lt;code&gt;ip addr | head -n 20&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F440kxqhw4ee5bwm2jtzp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F440kxqhw4ee5bwm2jtzp.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;loopback&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;enp0s3:&lt;/strong&gt; NAT Adapter&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;enp0s8:&lt;/strong&gt; Host-Only Adapter&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now we know we have to assign an IP to the &lt;strong&gt;enp0s8&lt;/strong&gt; device. To get its connection name, you have to execute the following statement:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;nmcli -p device&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3p04bn0zmqw1qak73k42.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3p04bn0zmqw1qak73k42.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The connection name is “Ethernet connection 1”.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 3: Configure connection IP
&lt;/h3&gt;

&lt;p&gt;There are two ways of doing it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Graphically with &lt;code&gt;nmtui&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;With bash statements and &lt;code&gt;nmcli&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In our case, we will execute some statements in the console.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;connection_name="Ethernet connection 1"
ip=192.168.56.2
gateway=192.168.56.1
bits=24

nmcli con mod "$connection_name" ipv4.addresses $ip/$bits
nmcli con mod "$connection_name" ipv4.gateway $gateway
nmcli con mod "$connection_name" ipv4.method manual
nmcli con up "$connection_name"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we execute &lt;code&gt;ip addr | head -n 20&lt;/code&gt; again, we will see the previous IP address.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgerhssmowem6szxzwvfr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgerhssmowem6szxzwvfr.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Reboot
&lt;/h3&gt;

&lt;p&gt;The last step is to reboot the VM&lt;/p&gt;

&lt;h2&gt;
  
  
  Test the connection
&lt;/h2&gt;

&lt;p&gt;Now we can connect to the VM using the command &lt;code&gt;ssh user@192.168.56.2&lt;/code&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Create Self-signed certificates with OpenSSL</title>
      <dc:creator>Paula</dc:creator>
      <pubDate>Sat, 04 Feb 2023 17:11:06 +0000</pubDate>
      <link>https://dev.to/pauladj/create-self-signed-certificates-with-openssl-jpa</link>
      <guid>https://dev.to/pauladj/create-self-signed-certificates-with-openssl-jpa</guid>
      <description>&lt;p&gt;In this guide, I give a step-by-step guide on how to create a self-signed CA and a certificate signed by using the OpenSSL command. Once you know how it works, you can create your own scripts to automate the process.&lt;/p&gt;

&lt;p&gt;The mentioned OpenSSL command is a utility that lets you create and inspect certificates.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a Self Signed Certificate?
&lt;/h2&gt;

&lt;p&gt;All computers come with a bunch of pre-installed CA. When you go to &lt;a href="https://google.com" rel="noopener noreferrer"&gt;https://google.com&lt;/a&gt; you can see a lock to the left of the URL. This means you trust the site certificates. In other words, your computer trusts the CA of the Google certificate.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu8gmvy9p07xo2xpo8cf6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu8gmvy9p07xo2xpo8cf6.png" alt="Image description" width="649" height="299"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With a self-signed certificate, this doesn't happen. The browser throws a warning indicating there's a security risk because you don't trust the certificate. You don't trust the CA that signed that certificate.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzc0f8fydomacrdw58cn8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzc0f8fydomacrdw58cn8.png" alt="Image description" width="800" height="475"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you don't want to see this warning, you have to install the CA. That way you are telling the browser to trust the certificates signed by that CA.&lt;/p&gt;

&lt;h3&gt;
  
  
  Benefits
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;You don't need to pay to have a CA&lt;/li&gt;
&lt;li&gt;If you need to establish secure connections with TLS but can't use third parties to sign your certificates&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Drawbacks
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;You'll need to trust the CA in the browser or application manually&lt;/li&gt;
&lt;li&gt;You have to be careful about where you save the private keys&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Create Certificate Authority
&lt;/h2&gt;

&lt;p&gt;First, we need to create our own root CA that will sign our certificates. If we trust in this CA, we trust in the certificates.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Create the Private Key
&lt;/h3&gt;

&lt;p&gt;Execute the following &lt;code&gt;openssl&lt;/code&gt; command to generate the private key.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;openssl genrsa -aes128 \
      -out rootCA.key \
      -passout pass:ca_12345 4096
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Encryption:&lt;/strong&gt; &lt;code&gt;-aes128&lt;/code&gt;. The &lt;a href="https://www.openssl.org/docs/man1.1.1/man1/openssl-genrsa.html" rel="noopener noreferrer"&gt;allowed options&lt;/a&gt; are: &lt;code&gt;-aes128, -aes192, -aes256, -aria128, -aria192, -aria256, -camellia128, -camellia192, -camellia256, -des, -des3, -idea&lt;/code&gt;. Some, such as &lt;code&gt;-des&lt;/code&gt; and &lt;code&gt;-des3&lt;/code&gt; are not considered secure anymore.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Private Key Size:&lt;/strong&gt; 4096. The minimum size is 2048. I always use 4096 for the CA, as seen in the Google Root CA.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F11zp6aahjqjqf0xoz7zl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F11zp6aahjqjqf0xoz7zl.png" alt="Image description" width="800" height="278"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Create the Certificate
&lt;/h3&gt;

&lt;p&gt;We will create the self-signed public certificate using the private key.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;openssl req -new -x509 \
      -days 3650 -sha256 \
      -key rootCA.key \
      -passin pass:ca_12345 -out rootCA.crt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Signature Hash algorithm:&lt;/strong&gt; &lt;code&gt;-sha256&lt;/code&gt;
You can execute &lt;code&gt;openssl list --digest-commands&lt;/code&gt; to see the available ones. Google uses &lt;code&gt;sha384&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsa71oufbucjvs8rcv24e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsa71oufbucjvs8rcv24e.png" alt="Image description" width="734" height="117"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Days until it's not valid:&lt;/strong&gt; 3650&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To view the certificate you've just created, you can use the following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;openssl x509 -in rootCA.crt -noout -text&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Create Self-Signed Certificates
&lt;/h2&gt;

&lt;p&gt;Follow the following steps below to create self-signed certificates. These certificates will be signed by the root CA we created in the previous step.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Create the Private Key
&lt;/h3&gt;

&lt;p&gt;As we did with the root CA, we need to create a Private key. This time we'll use 2048 as the size. In case of doubt, you can explore big companies' certificates to see how they do it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;openssl genrsa -aes128 \
      -out serverCert.key \
      -passout pass:server_12345 2048
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Create Certificate Configuration
&lt;/h3&gt;

&lt;p&gt;We will create a &lt;code&gt;serverCert.conf&lt;/code&gt; to have all the certificate data in one place.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;cat &amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;csr.conf &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;
&lt;/span&gt;&lt;span class="go"&gt;[ req ]
prompt = no
distinguished_name = requested_distinguished_name
req_extensions = requested_extensions
x509_extensions = requested_extensions

[ requested_distinguished_name ]
countryName = ES
stateOrProvinceName = Madrid
localityName = Madrid
organizationName = Mock Organization
organizationalUnitName = Mock Organization Devops
commonName = mockorg.com
emailAddress = devops@mockorg.com

[ requested_extensions ]
basicConstraints = CA:FALSE
subjectAltName = @list_of_alternative_names

[ list_of_alternative_names ]
DNS.1 = mockorg.com
DNS.2 = www.mockorg.com
DNS.3 = devops.mockorg.com

EOF
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Generate a CSR (Certificate Signing Request)
&lt;/h3&gt;

&lt;p&gt;The next step is to generate the file &lt;code&gt;serverCert.csr&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;openssl req -new -sha256 \
      -config serverCert.conf \
      -key serverCert.key -passin pass:server_12345 \
      -out serverCert.csr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Generate Certificate
&lt;/h3&gt;

&lt;p&gt;The last step is to generate the certificate using the just-created CSR.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;openssl x509 -req -days 1460 -sha256 -in serverCert.csr \
    -CA rootCA.crt -CAkey rootCA.key -CAcreateserial \
    -out serverCert.crt -passin pass:ca_12345 \
    -extensions requested_extensions -extfile serverCert.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To view the certificate you've just created, you can use the following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;openssl x509 -in serverCert.crt -noout -text&lt;/code&gt;&lt;/p&gt;

</description>
      <category>devto</category>
      <category>announcement</category>
      <category>support</category>
    </item>
  </channel>
</rss>
