How to generate ssl certificate? Use this four commands to generate self-signed certificate:
openssl genrsa -out server.key 2048
openssl rsa -in server.key -out server.pem
openssl req -new -key server.key -out server.csr
openssl x509 -req -days 3560 -in server.csr -signkey server.key -out server.crt
If you need ssl certificate signed by some CA (eg. Startssl, GoDaddy), just skip last step. Instead, you will upload certificate request (csr file) trought CA web interface to sign it.