Create a directory in your user root directory where we will store the necessary generated files.
$ cd ~/
$ mkdir .localhost
$ cd .localhost
Now run this single command and you will have both a certificate and private key which was used to sign the certificate.