Self signed certificate in macOS Sierra

To add self signed certificates in macOS Sierra for testing, you need to create root CA certificate signed with SHA256

openssl req -x509 -nodes -sha256 -days 365 -newkey rsa:2048 -keyout localhost.key -out localhost.cert

and add it to System keychain using

sudo security add-trusted-cert -d -r trustAsRoot -k /Library/Keychains/System.keychain