熱門分類
載入中…
目錄0%

🪟 Windows CA 憑證服務(AD CS)架設全攻略:企業憑證、Auto-Enrollment、HTTPS/SMB/EAP 實務應用

    🪟 Windows CA 憑證服務(AD CS)架設全攻略:企業憑證、Auto-Enrollment、HTTPS/SMB/EAP 實務應用

    在企業網路中,憑證(Certificate) 是支撐安全架構的核心:HTTPS、SMB 簽署、Wi-Fi EAP-TLS、VPN、RDP、Intune、SQL Server… 這些都需要可靠的 PKI(Public Key Infrastructure)來管理憑證,而在 Windows 企業 AD 環境中最完整的方案就是 AD CS(Active Directory Certificate Services)

    本文將手把手帶你完成 Windows 企業內部 CA 架設、憑證範本設計、Auto-Enrollment、服務憑證佈署、EAP-TLS Wi-Fi 驗證、憑證管理 等全部流程, 打造可正式上線的企業級 PKI 服務。


    📑 目錄


    一、AD CS 與企業 PKI 架構概念

    AD CS 是 Windows Server 的 PKI 服務,負責:

    • 簽發憑證(Issue Certificates)
    • 撤銷憑證、發布 CRL
    • 憑證範本、申請規則、使用者授權
    • 整合 Active Directory,自動派發憑證(Auto-Enrollment)

    企業中常用憑證用途包括:

    • Windows Server / IIS HTTPS
    • SMB 簽署 / LDAP over SSL
    • Wi-Fi 802.1X(EAP-TLS)
    • VPN(SSTP、OpenVPN、FortiGate、IPsec)
    • SQL Server / Exchange
    完整 PKI 架構示意:
    
           Root CA(離線)
               │
               ▼
          Issuing CA(線上)
               │
               ├── 使用者憑證(User / SmartCard)
               ├── 電腦憑證(Computer / Workstation)
               ├── 伺服器憑證(Web / RDP / LDAP)
               └── 網路憑證(EAP-TLS / VPN)
    

    二、PKI 角色:Root CA、Sub CA、Issuing CA

    建議企業環境採用兩層架構:

    1. Root CA(離線)

    • 只用來簽發 Sub CA(Issuing CA)憑證
    • 平時不開機、不上網、不加入 AD
    • 金鑰安全性極高

    2. Issuing CA(線上)

    • 直接簽發所有使用者與伺服器憑證
    • 整合 AD、GPO,自動派發憑證
    • 日常營運的 CA

    如果公司規模小(約 50 人內),可允許使用單層 Enterprise Root CA(本文示範此架構)。


    三、安裝 AD CS:Enterprise Root CA

    1. 安裝 AD CS 角色

    # Windows Server GUI 操作
    Server Manager → Add Roles and Features → Active Directory Certificate Services
    
    勾選:
    ✓ Certification Authority
    ✓ Certification Authority Web Enrollment(可選)
    

    2. 設定 AD CS

    角色安裝完成後,執行「Configure AD CS」。

    • CA 類型:Enterprise CA
    • 層級:Root CA
    • 金鑰長度:建議 4096 bit
    • Hash 演算法:SHA256
    • CA 有效期限:10–20 年(依企業政策)

    3. 檢查 CA 是否運作正常

    certsrv.msc  → Certification Authority
    
    查看:
    ✓ CA 啟動成功
    ✓ 無 Error
    ✓ CRL 已發布

    四、憑證範本(Certificate Template)設計

    在企業運作中,不會手動為每台電腦申請憑證,而是透過憑證範本(Certificate Template)統一管理類型與屬性。

    常見範本:

    • Computer(電腦憑證)
    • User(使用者憑證)
    • Web Server(HTTPS)
    • Smart Card Login / EAP-TLS(Wi-Fi)

    1. 建立範本(以 Computer 範本為例)

    certtmpl.msc → 右鍵複製 "Computer" → 新範本命名為 "Corp-Computer-Cert"

    2. 設定安全性(Security)

    • 允許 Domain Computers:Enroll + Autoenroll

    3. 發佈範本

    certsrv.msc → Certificate Templates → New → Certificate Template to Issue
    
    選取:
    ✓ Corp-Computer-Cert

    五、Auto-Enrollment 自動派發憑證(使用 GPO)

    1. 建立 GPO

    gpmc.msc → Create GPO → "PKI Auto Enrollment"

    2. 啟用自動憑證派發

    Computer Configuration →
      Policies →
        Windows Settings →
          Security Settings →
            Public Key Policies →
              Certificate Services Client – Auto-Enrollment →
                ✓ Enabled
                ✓ Renew expired certificates
                ✓ Update certificates
                ✓ Enroll certificates automatically
    

    3. 套用到 OU

    將 GPO 套用至:
    OU = Workstations
    OU = Servers

    4. 立即驗證

    gpupdate /force
    
    certmgr.msc → 是否出現 "Corp-Computer-Cert"

    六、服務應用:HTTPS、RDP、SMB、EAP-TLS

    1. IIS / HTTPS 憑證

    網站安全加密、反向代理、API Server 都需要 Web Server 憑證。

    IIS Manager →
    Server Certificates →
    Create Domain Certificate →
    選擇 CA →
    完成後綁定 HTTPS 埠口(443)
    

    2. RDP 憑證(取代自簽 RDP 憑證)

    gpedit.msc →
    Computer Configuration →
    Administrative Templates →
    Windows Components →
    Remote Desktop Services →
    Remote Desktop Session Host →
    Security →
    選擇憑證:Corp-Computer-Cert
    

    3. SMB 簽署(SMB Signing / LDAP over SSL)

    使 File Server / AD DS 角色提供更安全的加密。

    4. Wi-Fi EAP-TLS(802.1X + NPS)

    最安全的企業 Wi-Fi 認證方式:

    • 無密碼、無可重放攻擊
    • 結合 Auto-Enrollment 全自動發憑證
    步驟概要:
    NPS → RADIUS Server
    憑證:Server 與 Client 均使用 AD CS 的範本
    AP → 設定 802.1X(WPA2-Enterprise)
    Client → 安裝/自動取得個人憑證(EAP-TLS)
    

    七、CRL / OCSP:憑證撤銷與線上查詢

    安全政策需要可「撤銷」憑證,例如:員工離職、裝置遺失。

    1. 撤銷憑證

    certsrv.msc → Issued Certificates → 右鍵 Revoke

    2. 確保 CRL 可被 Client 存取

    企業常使用:

    • CRL Distribution Point(CDP):HTTP
    • AIA:HTTP
    若要啟用 OCSP,可另安裝 Online Responder:
    Server Manager → Add Roles → Active Directory Certificate Services →
    ✓ Online Responder

    八、PKI 維護:CA 備份、金鑰保護、憑證到期

    1. 備份 CA 金鑰與資料庫

    certutil -backupkey C:\CA-Backup
    certutil -backupdb C:\CA-Backup

    2. 憑證有效期限與更新

    企業應建立「憑證到期監控」,例如 SQL、IIS、NPS 等服務的憑證。

    3. AD CS 移機 / 災難復原

    僅需:CA 金鑰、CA Database、CA 設定。


    九、錯誤排查與診斷

    1. 憑證沒有自動派發

    • GPO 沒套用
    • 範本未允許 Autoenroll
    • CA 未 Publish 範本

    2. HTTPS 無法綁定憑證

    • 缺少 Private Key
    • 憑證無 Server Authentication EKU

    3. Wi-Fi EAP-TLS 無法登入

    • Client 未取得個人憑證
    • NPS 未安裝 Server 憑證

    — WWFandy・Windows PKI 筆記

    🔗 分享這篇 LINE Facebook X

    沒有留言:

    字級