Home > SSL > Create a certificate for localhost on Mac OS

1. Generate cert

openssl req -x509 -out www.my-helper.test.crt -keyout www.my-helper.test.key \
-newkey rsa:2048 -nodes -sha256 \
-subj '/CN=www.my-helper.test' -extensions EXT -config <( \
printf "[dn]\nCN=www.my-helper.test\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:www.my-helper.test\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")

2. Add the certificate to Keychain Access

sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain www.my-helper.test.crt

3. Update Apache config

<VirtualHost 127.0.0.1:443>
...
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile /Applications/AMPPS/www/my-helper.test/certs/www.my-helper.test.crt
SSLCertificateKeyFile /Applications/AMPPS/www/my-helper.test/certs/www.my-helper.test.key
</VirtualHost>

Reference:
https://letsencrypt.org/docs/certificates-for-localhost/
https://gist.github.com/jonathantneal/774e4b0b3d4d739cbc53



Flag Counter