How to configure HTTPS in IIS Windows Server via PowerShell
Berikut langkah-langkah konfigurasi HTTPS pada IIS di Windows Server menggunakan PowerShell.
Tutorial ini fokus pada proses:
- Import sertifikat PFX
- Binding sertifikat ke website IIS
- Verifikasi HTTPS
📌 Prasyarat
Sebelum memulai, pastikan:
- Web server IIS sudah terinstall
- Sudah memiliki sertifikat format PFX
- Sertifikat berasal dari CA internal / external
Referensi terkait:
-
Konfigurasi IIS via PowerShell (HTTP):
https://nciptandani.blogspot.com/2019/06/cara-konfigurasi-web-server-iis-di.html -
Setup Windows CA & template webserver:
https://nciptandani.blogspot.com/2018/08/pembahasan-itnsa-module-b-windows-ca.html
🪪 Mendapatkan Sertifikat PFX
Sertifikat bisa dibuat dari:
- Template Web Server di CA
- Request melalui MMC:
MMC → Certificates → Local Computer → Personal
→ Right Click Certificates → All Tasks → Request New Certificate
Isi dengan benar:
- Common Name (CN)
- Subject Alternative Name (SAN)
Kemudian export menjadi PFX dari server CA.
Tutorial export PFX:
https://www.youtube.com/watch?v=m157RGX6S1g
1️⃣ Import Sertifikat ke IIS Server
Buat Variabel Password PFX
$Password = ConvertTo-SecureString -AsPlainText -Force "P@ssw0rd"
Import Sertifikat ke Store Local Machine
Lokasi sertifikat:
Cert:\LocalMachine\My
Perintah import:
Import-PfxCertificate `
-FilePath C:\Users\Administrator\window.id.pfx `
-CertStoreLocation Cert:\LocalMachine\My `
-Password $Password
🔎 Cek Sertifikat yang Ter-Import
Get-ChildItem Cert:\LocalMachine\My
Contoh output:
Thumbprint Subject
---------- -------
228940060FF922175C2F435A135FD1CB26FC3A84 CN=window.id
2️⃣ Konfigurasi SSL Binding di IIS
Simpan Sertifikat ke Variabel
$Cert = Get-ChildItem Cert:\LocalMachine\My\228940060FF922175C2F435A135FD1CB26FC3A84
Lihat Website IIS
Get-Website
Contoh:
window.id Started http *:80:window.id
Tambahkan HTTPS Binding
New-WebBinding `
-Name "window.id" `
-IPAddress "*" `
-HostHeader "window.id" `
-Port 443 `
-Protocol https
Attach Sertifikat ke Binding
New-Item IIS:\SslBindings\0.0.0.0!443!window.id -Value $Cert
🔎 Verifikasi Binding
Get-Website
Hasil akan menampilkan:
https *:443:window.id sslFlags=0
3️⃣ Verifikasi Akses HTTPS
Test menggunakan curl:
curl.exe https://window.id
Jika menggunakan self-signed certificate, tambahkan opsi:
curl.exe -k https://window.id
💡 Catatan Penting
- Jalankan PowerShell sebagai Administrator
- Pastikan DNS / hosts file sudah mengarah ke IP server
- Pastikan port 443 terbuka di firewall
📌 Kesimpulan
Dengan langkah di atas:
✅ Sertifikat berhasil di-import ke Windows
✅ HTTPS binding dibuat di IIS
✅ Website sudah bisa diakses via SSL
Komentar