Quick! create a self-signed SSL certificate in Ubuntu
Especially for testing SSL, I can never remember how to create a self-signed certificate. Here’s a quick and dirty guide to setting up a self-signed certificate. Obviously, not recommended for production setups
We will create the certificate in the “/etc/ssl/self-signed” directory
# Become root first !
$ mkdir /etc/ssl/self-signed && cd /etc/ssl/self-signed
$ openssl genrsa -des3 -out server.key 1024
$ openssl rsa -in server.key -out server.key.insecure
$ mv server.key server.key.secure && mv server.key.insecure server.key
$ openssl req -new -key server.key -out server.csr
$ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Now, you can use the files server.key and server.crt in your web server setups. See my post on Setting up Node.js with to accept HTTP and HTTPS connections for a quick example of using this SSL certificate with Node.js!

[...] In the example, we created a self-signed SSL certificate. If you need help on that, check out this quick guide on how to set up a self-signed SSL certificate on Ubuntu. [...]
Node.js and RESTify Server with both HTTP and HTTPS at A Waage Blog
27 Feb 12 at 4:22 pm
3 of those commands are removing the password you set with -des3. Here’s a one liner:
openssl genrsa -out server.key 2048 && openssl req -new -key server.key -out server.csr && openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Chris LeBlanc
16 Apr 12 at 4:12 pm