How to configure HTTPS in IIS Windows Server via PowerShell

Konfigurasi HTTPS di IIS Windows Server Menggunakan PowerShell

Berikut langkah-langkah konfigurasi HTTPS pada IIS di Windows Server menggunakan PowerShell.

Tutorial ini fokus pada proses:

  1. Import sertifikat PFX
  2. Binding sertifikat ke website IIS
  3. Verifikasi HTTPS

📌 Prasyarat

Sebelum memulai, pastikan:

  • Web server IIS sudah terinstall
  • Sudah memiliki sertifikat format PFX
  • Sertifikat berasal dari CA internal / external

Referensi terkait:


🪪 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

Postingan populer dari blog ini

Cara restart / stop windows service (services.msc) dengan bat / cmd

Learning Haproxy Load Balancer with Podman and Go Backends

Konfigurasi ITNSA OpenVPN auth LDAP