One line command to create a Self Signed certificate on Mac
You need an SSL certificate to secure your website or app, and sometimes you do not want to spend money on the public signing authorities to sign your certificate for various reasons. One reason might be that you are only running a an app on a subdomain and that subdomain will not host a website, in which case your app/website will not be opened from any browser, because if the certificate is not signed by a signing authority the browser will not know the authenticity of the certificate and will complain about it.
One of the simplest ways I have found to create a key and self signed certificate using the openssl package on mac is this:
openssl req -x509 -nodes -days 10365 -newkey rsa:2048 -keyout app.example.com.key -out app.example.com.key.crt
Here replace the days with your own expiry num of days for the certificate, rsa number of bits for which i used 2048, it is recommended to use 4096 for production env and replace example.com with your own domain name and voila you have your self signed certificate and key.
How to use the self signed key and certificate in your nodejs application? Find out here












