Skip to content

Instantly share code, notes, and snippets.

@jkga
Last active September 28, 2020 07:11
Show Gist options
  • Save jkga/8acf4f2c5983424555622845d2f9c683 to your computer and use it in GitHub Desktop.
Save jkga/8acf4f2c5983424555622845d2f9c683 to your computer and use it in GitHub Desktop.
enable https(SSL) in localhost (https://localhost) -for WINDOWS 10
1.) download openssl
> https://www.cloudinsidr.com/content/how-to-install-the-most-recent-version-of-openssl-on-windows-10-in-64-bit/
2.) run openssl comand line - C:\OpenSSL-Win64\bin
3.) Generate rootCA - certification authority
> genrsa -des3 -out rootCA.key 2048
> req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem
> x509 -outform pem -in rootCA.pem -out rootCA.crt
> please refer to full article https://www.freecodecamp.org/news/how-to-get-https-working-on-your-local-development-environment-in-5-minutes-7af615770eec/
4.) Click the generated "rootCA.crt" and select "install" > "local machine" > browse from stores > "Trusted Root Certification Authorities"
5.) create new file "server.csr.cnf"
> Paste the code below
[req]
default_bits = 2048
prompt = no
default_md = sha256
distinguished_name = dn
[dn]
C=US
ST=RandomState
L=RandomCity
O=RandomOrganization
OU=RandomOrganizationUnit
emailAddress=hello@example.com
CN = localhost
6.) create file "domains.ext" and paste the code below
> authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = localhost
7.) run the code in openssl comand line
> req -new -sha256 -nodes -out server.csr -newkey rsa:2048 -keyout server.key -config server.csr.cnf
> x509 -req -in server.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out server.crt -days 500 -sha256 -extfile domains.ext
8.) Apache vhost config
> paste the code below in vhost config file
<VirtualHost *:443>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
SSLEngine on
SSLCertificateFile "C:/OpenSSL-Win64/bin/server.crt"
SSLCertificateKeyFile "C:/OpenSSL-Win64/bin/server.key"
<Directory "C:/xampp/htdocs">
Options All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
9.) restart apache
10.) visit https://localhost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment