# Linux - Generate Self SSL (Localhost HTTPS/SSL)

In this article, I'll walk you through the steps to generate a self-signed SSL certificate for [localhost](http://localhost) on a Linux system. We'll use `mkcert`, a simple tool for making locally trusted development certificates. Also just to highlight it, I’m using arm base processor, so I use arm64 version.

#### Step 1: Download and Install mkcert

First, we need to download the `mkcert` binary and make it executable:

sh

```bash
curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/arm64"
chmod +x mkcert-v*-linux-amd64
sudo cp mkcert-v*-linux-amd64 /usr/local/bin/mkcert
```

#### Step 2: Generate the SSL Certificate

Next, we'll use `mkcert` to generate the SSL certificate and key for [localhost](http://localhost):

sh

```bash
mkcert -key-file testing-key.pem -cert-file testing-cert.pem testing-dev.fiko.me
```

This command will create [`localhost`](http://localhost)`-key.pem` and [`localhost`](http://localhost)`-cert.pem` files.

#### Step 3: Configure Nginx

Now, let's configure Nginx to use the generated SSL certificate. Add the following configuration to your Nginx server block:

nginx

```bash
server {
    listen 445 ssl;
    server_name testing-dev.fiko.me;
    set $MAGE_ROOT /home/fiko/sites/testing;
    set $MAGE_MODE developer; # or production, depending on your environment

    ssl_certificate /home/fiko/downloads/testing-cert.pem;
    ssl_certificate_key /home/fiko/downloads/testing-key.pem;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;

    include /home/fiko/sites/testing/nginx.conf.sample;

    error_page  404  /errors/404.php;
    error_page  500 502 503 504  /errors/503.php;

    access_log /var/log/nginx/testing_ssl.access.log;
    error_log /var/log/nginx/testing_ssl.error.log;
}
```

Make sure the paths to the SSL certificate and key files are correct.

#### Step 4: Restart Nginx

Finally, restart Nginx to apply the new configuration:

sh

```bash
sudo systemctl restart nginx
```

Your Nginx server should now be serving the site over HTTPS using the self-signed certificate.

### References

* [mkcert GitHub Repository](https://github.com/FiloSottile/mkcert)
    

By following these steps, you can generate a self-signed SSL certificate for [localhost](http://localhost) and configure Nginx to use it. This setup is great for development environments where you need HTTPS but don't want to obtain a certificate from a Certificate Authority.

Happy coding! 😊
