Skip to content

Instantly share code, notes, and snippets.

@devyfriend
Last active August 23, 2020 00:15
Show Gist options
  • Save devyfriend/8fbb5d06c1c07521e7498307cbf607c0 to your computer and use it in GitHub Desktop.
Save devyfriend/8fbb5d06c1c07521e7498307cbf607c0 to your computer and use it in GitHub Desktop.
ssl certificate - one for all
#usage: openssl req -config openssl.cnf -new -x509 -days 825 -out localhost.crt
==============================================================================================================================
#file: openssl.cnf
[ req ]
default_bits = 2048
default_keyfile = localhost.key
default_md = sha256
default_days = 825
encrypt_key = no
distinguished_name = subject
req_extensions = req_ext
x509_extensions = x509_ext
string_mask = utf8only
prompt = no
[ subject ]
countryName = ID
stateOrProvinceName = XXX
localityName = XXX
organizationName = XXX
OU = XXX
commonName = localhost.local
emailAddress = alamat@email.com
[ x509_ext ]
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer
basicConstraints = critical, CA:TRUE
extendedKeyUsage = critical, digitalSignature, keyEncipherment, cRLSign, keyCertSign
subjectAltName = DNS:localhost.local
extendedKeyUsage = serverAuth
extendedKeyUsage = TLS Web Server Authentication
[ req_ext ]
subjectKeyIdentifier = hash
basicConstraints = CA:FALSE
keyUsage = digitalSignature, keyEncipherment
nsComment = "OpenSSL Generated Certificate"
subjectAltName = DNS:localhost.local
#subjectAltName = @alt_names
#[ alt_names ]
#DNS.1 = localhost
#source: https://stackoverflow.com/questions/57565665/one-self-signed-cert-to-rule-them-all-chrome-android-and-ios
=====================================================================================================================================
#file: httpd.conf
# Secure (SSL/TLS) connections
Include conf/extra/httpd-ssl.conf
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Include conf/extra/httpd-vhosts-ssl.conf
#NOTE: change the include order
==================================================================================================================================
#file: httpd-vhosts-ssl.conf
<VirtualHost *:443>
ServerName localhost.local
DocumentRoot "${INSTALL_DIR}/www/localhost"
SSLEngine on
SSLCertificateFile "${INSTALL_DIR}/www/keys/localhost.crt"
SSLCertificateKeyFile "${INSTALL_DIR}/www/keys/localhost.key"
</VirtualHost>
==================================================================================================================================
#file: C:\Windows\System32\drivers\etc\hosts
127.0.0.1 localhost.local
::1 localhost.local
==================================================================================================================================
NOTES:
- email the localhost.crt and open&install on android device as vpn&apps and wifi
- setup router static dns & add localhost.crt to system (win/mac)
- setup virtualhosts (wamp/mamp)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment