How Can I implement a secure https connection on ngnix

I want to implement https on my localhost.I am running http server nginx on ubuntu 20.04

What I did was i issued the command

sudo openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /etc/ssl/private/localhost.key -out /etc/ssl/certs/localhost.crt -config /tmp/openssl

Then I configured nginx to use ssl as

   listen 443 ssl default_server;
    listen [::]:443 ssl default_server;
    ssl_certificate /etc/ssl/certs/localhost.crt;
    ssl_certificate_key /etc/ssl/private/localhost.key;

And Refreshed and reloaded nginix ...ok fine

certutil -d sql:$HOME/.pki/nssdb -A -t "P,," -n localhost.crt -i /etc/ssl/certs/localhost.crt

. .Every thing went fine

The tutorial i followed was from here

But when i tried to connect to https://localhost

I got as

enter image description here

Then I clicked Advance and proceeded ..Then I got a MOZILLA_PKIX_ERROR_SELF_SIGNED_CERT Error in Firefox

enter image description here

But when opening in chrome the error is

enter image description here

when i tried on wget

enter image description here

When I tried on postman

enter image description here

Please help me on how to get a secure self signed trusted https connection on localost

  • How can I implement a secure HTTPS connection on Ngnix? - Arguably, you appear to have already done this (i.e. set up Nginx to correctly serve your self-signed certificate). The issue(s) you are encountering are simply generic security warnings generated by each application individually. This means, unfortunately, that there really isn't a single way to prevent these (though it is possible to add your own trusted Certificate Authority or similar, which might alleviate some of the problem). – Anaksunaman May 11 at 2:34
  • The simplest ways to get around the problem of self-signed certificates is to add security exceptions to your browser(s) (if possible), often under the Advanced menu or to use the other clear options to bypass verifying security certificates shown in your screenshots. An secure HTTPS connection should still be established, minus the warnings. – Anaksunaman May 11 at 2:37
  • @Anaksunaman described it beautifully. Regarding wget, use option --no-check-certificate. In case you want to try curl, the equivalent option is -k. Finally, it is not too hard to create your own CA and add it to your browsers and the command line tools. Tutorials about this should be easy to find. A good exercise in my opinion. – berndbausch May 11 at 3:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.