openssl create self signed certificate code example
Example 1: generate key and certificate openssl
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365
Example 2: create self signed certificate for localhost ubuntu
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/apache-selfsigned.key -out /etc/ssl/certs/apache-selfsigned.crt
Example 3: openssl generate self signed certificate
openssl.exe genrsa -out <yourcertname>.key 4096
openssl.exe req -new -key yourcertname.key -out yourcertname.csr