Skip to content

Instantly share code, notes, and snippets.

@hijoem
Last active July 6, 2021 20:15
Show Gist options
  • Save hijoem/4029e291c1b250902ef62094eb8fc86e to your computer and use it in GitHub Desktop.
Save hijoem/4029e291c1b250902ef62094eb8fc86e to your computer and use it in GitHub Desktop.
Cara akses https melalui XAMPP di Windows
[ req ]
default_bits = 2048
default_keyfile = server-key.pem
distinguished_name = subject
req_extensions = req_ext
x509_extensions = x509_ext
string_mask = utf8only
[ subject ]
countryName = Country Name (2 letter code)
countryName_default = US
stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = NY
localityName = Locality Name (eg, city)
localityName_default = New York
organizationName = Organization Name (eg, company)
organizationName_default = Example, LLC
commonName = Common Name (e.g. server FQDN or YOUR name)
commonName_default = local.test
emailAddress = Email Address
emailAddress_default = test@example.com
[ x509_ext ]
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer
basicConstraints = CA:FALSE
keyUsage = digitalSignature, keyEncipherment
subjectAltName = @alternate_names
nsComment = "OpenSSL Generated Certificate"
[ req_ext ]
subjectKeyIdentifier = hash
basicConstraints = CA:FALSE
keyUsage = digitalSignature, keyEncipherment
subjectAltName = @alternate_names
nsComment = "OpenSSL Generated Certificate"
[ alternate_names ]
DNS.1 = local.test
# Buka file C:\Windows\System32\drivers\etc\host
# Tambahkan kode berikut di baris paling bawah
127.0.0.1 local.test
# Buka file C:\xampp\apache\conf\extra\httpd-xampp.conf
# Tambahkan kode berikut di baris paling bawah
## local.test
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName local.test
ServerAlias *.local.test
</VirtualHost>
<VirtualHost *:443>
DocumentRoot "C:/xampp/htdocs"
ServerName local.test
ServerAlias *.local.test
SSLEngine on
SSLCertificateFile "crt/local.test/server.crt"
SSLCertificateKeyFile "crt/local.test/server.key"
</VirtualHost>
@echo off
REM Buka C:\xampp\apache\ lalu buat folder crt dan masukkan cert.conf dan make-cert.bat kedalamnya
REM sehingga susunannya seperti berikut.
REM
REM C:\xampp\apache\crt\cert.conf
REM C:\xampp\apache\crt\make-cert.bat
REM
REM Klik 2x make-cert.bat tekan Enter hingga selesai
REM Akan ada folder baru C:\xampp\apache\cert\local.test yang berisi server.crt dan server.key
REM Klik 2x server.crt lalu Install Certificate ...
REM Pilih Local Machine > Next
REM Pilih Place all certificates in the following store > Browse...
REM Pilih Trusted Root Certidication Authorities > Ok > Next > Finish
REM Edit file C:\Windows\System32\drivers\etc\host sesuai contoh
REM Edit file C:\xampp\apache\conf\extra\httpd-xampp.conf sesuai contoh
REM Restart Apache di XAMPP dan juga browser
REM Silahkan akses https://local.test di browser
REM
REM
REM ---------------------------------------------------------------------------
REM - This tutorial is modified from:
REM - https://shellcreeper.com/how-to-create-valid-ssl-in-localhost-for-xampp/
REM - Tested on XAMPP Control Panel V3.3.0 at 17 July 2021 on Windows 10 x64
REM
REM - Kindly visit https://www.hijoem.my.id/ and https://hijoem.com
REM ---------------------------------------------------------------------------
REM
set domain="local.test"
set OPENSSL_CONF=../conf/openssl.cnf
if not exist .\%domain% mkdir .\%domain%
..\bin\openssl req -config cert.conf -new -sha256 -newkey rsa:2048 -nodes -keyout %domain%\server.key -x509 -days 365 -out %domain%\server.crt
echo.
echo -----
echo The certificate was provided. You can close this window and install the new certificate.
echo.
pause
.\%domain%\server.crt
@hijoem
Copy link
Author

hijoem commented Jul 6, 2021

This tutorial is modified from: https://shellcreeper.com/how-to-create-valid-ssl-in-localhost-for-xampp/
Tested on XAMPP Control Panel V3.3.0 at 7 July 2021 on Windows 10 x64

Kindly visit https://www.hijoem.my.id/ and https://hijoem.com

  • Buka C:\xampp\apache\ lalu buat folder crt dan masukkan cert.conf dan make-cert.bat kedalamnya sehingga susunannya seperti berikut:
    • C:\xampp\apache\crt\cert.conf
    • C:\xampp\apache\crt\make-cert.bat
  • Klik 2x make-cert.bat tekan Enter hingga selesai
  • Akan ada folder baru C:\xampp\apache\cert\local.test yang berisi server.crt dan server.key
  • Klik 2x server.crt lalu Install Certificate ...
  • Pilih Local Machine > Next
  • Pilih Place all certificates in the following store > Browse...
  • Pilih Trusted Root Certification Authorities > Ok > Next > Finish
  • Edit file C:\Windows\System32\drivers\etc\host sesuai contoh
  • Edit file C:\xampp\apache\conf\extra\httpd-xampp.conf sesuai contoh
  • Restart Apache di XAMPP dan juga browser
  • Silahkan akses https://local.test di browser

Semoga berhasil.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment