Create a new key and certificate request
$ openssl req -new -newkey rsa:2048 -keyout example.com -nodes -out example.com.csr
or create a certificate request with a given key
$ openssl req -new -key example.com -out example.com.csr
finally self sign the certificate