Dokumen ini berisi panduan langkah demi langkah untuk mengaktifkan HTTPS/SSL mandiri (*Self-Signed Certificate* dengan *Trusted Root CA*) pada web server XAMPP Apache di Windows Server / Local Server.
---
## 📌 Ringkasan Langkah
1. Membuat file konfigurasi OpenSSL SAN (`openssl_san.cnf`).
2. Menggenerasi sertifikat Root CA dan sertifikat server (`server.crt` & `server.key`).
3. Mengonfigurasi `httpd.conf` dan `httpd-ssl.conf` di Apache XAMPP.
4. Meng-import sertifikat `rootCA.crt` ke Windows Trusted Root Certification Authorities.
5. Memperbarui `config.php` CodeIgniter.
6. Memuat ulang (*restart*) service Apache.
---
## 🛠️ Langkah 1: Buat File Konfigurasi OpenSSL SAN
Buat file baru di server pada jalur berikut:
`C:\df\apache\conf\openssl_san.cnf`
Isi file dengan konfigurasi berikut (ganti `<IP_SERVER_ANDA>` dengan IP address server, misalnya `192.168.3.149`):
```ini
[ req ]
default_bits = 2048
distinguished_name = req_distinguished_name
req_extensions = req_ext
x509_extensions = v3_ca
prompt = no
[ req_distinguished_name ]
C = ID
ST = Jakarta
L = Jakarta
O = IT Center Local
OU = IT Department
CN = <IP_SERVER_ANDA>
[ req_ext ]
subjectAltName = @alt_names
[ v3_ca ]
subjectAltName = @alt_names
[ v3_req ]
basicConstraints = CA:FALSE
keyUsage = digitalSignature, keyEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[ alt_names ]
DNS.1 = localhost
DNS.2 = itcenter.local
IP.1 = <IP_SERVER_ANDA>
IP.2 = 127.0.0.1
```
---
## 🔑 Langkah 2: Generasi Sertifikat SSL Menggunakan Command Prompt
Buka **Command Prompt (cmd)** di server, lalu jalankan perintah berikut:
```cmd
:: 1. Pindah ke direktori ssl.crt Apache
cd /d C:\df\apache\conf\ssl.crt
:: 2. Set variabel lingkungan konfigurasi OpenSSL
set OPENSSL_CONF=C:\df\apache\conf\openssl.cnf
:: 3. Generate Root CA (Private Key & Certificate)
..\..\bin\openssl.exe req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout rootCA.key -out rootCA.crt -config ..\openssl_san.cnf -subj "/C=ID/ST=Jakarta/L=Jakarta/O=IT Center Authority/CN=IT Center Root CA"
:: 4. Generate Server Private Key & CSR
..\..\bin\openssl.exe req -new -nodes -newkey rsa:2048 -keyout ..\ssl.key\server.key -out server.csr -config ..\openssl_san.cnf
:: 5. Sign Server Certificate Menggunakan Root CA dan Extension SAN
..\..\bin\openssl.exe x509 -req -in server.csr -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out server.crt -days 3650 -extfile ..\openssl_san.cnf -extensions v3_req
```
---
## ⚙️ Langkah 3: Verifikasi Konfigurasi Apache
### 1. File `C:\df\apache\conf\httpd.conf`
Pastikan baris berikut **tidak diawali dengan tanda `#`** (aktif):
```apache
LoadModule ssl_module modules/mod_ssl.so
Include conf/extra/httpd-ssl.conf
```
### 2. File `C:\df\apache\conf\extra\httpd-ssl.conf`
Pastikan direktori sertifikat mengarah ke file yang baru dibuat:
```apache
SSLCertificateFile "conf/ssl.crt/server.crt"
SSLCertificateKeyFile "conf/ssl.key/server.key"
```
---
## 🛡️ Langkah 4: Registrasikan Root CA ke Windows Certificate Store
Agar browser (Chrome / Edge) mempercayai sertifikat tanpa muncul peringatan *"Not Secure"*, daftarkan file `rootCA.crt` ke **Trusted Root Store** Windows.
Jalankan perintah ini melalui **Command Prompt (Run as Administrator)** di server atau PC client:
```cmd
certutil -addstore -f "Root" "C:\df\apache\conf\ssl.crt\rootCA.crt"
```
*Atau secara manual:*
1. Buka folder `C:\df\apache\conf\ssl.crt\`
2. Klik ganda `rootCA.crt` ➔ **Install Certificate...**
3. Pilih **Local Machine** ➔ **Next**
4. Pilih **Place all certificates in the following store** ➔ Browse ➔ **Trusted Root Certification Authorities**
5. Klik **OK** ➔ **Next** ➔ **Finish**.
---
## 🌐 Langkah 5: Update Konfigurasi CodeIgniter
Perbarui URL dasar pada proyek CodeIgniter di file `application/config/config.php`:
```php
$config['base_url'] = 'https://<IP_SERVER_ANDA>/itcenter/';
```
---
## 🔄 Langkah 6: Restart Service Apache
Muat ulang service Apache dari **XAMPP Control Panel** (tombol **Stop** kemudian **Start**), atau jalankan perintah berikut di Command Prompt Administrator:
```cmd
net stop Apache2.4
net start Apache2.4
```
---
## 💡 Pengujian
1. Tutup seluruh jendela browser Chrome/Edge.
2. Buka halaman: `https://<IP_SERVER_ANDA>/itcenter/login`
3. Pastikan gembok aman (HTTPS) telah aktif tanpa peringatan merah.

0 comments:
Post a Comment