เอกสารนี้สรุปขั้นตอนทั้งหมดสำหรับการสร้าง, ตั้งค่า, และแจกจ่าย Certificate สำหรับการยืนยันตัวตนผ่านเครือข่ายด้วยมาตรฐาน 802.1X โดยใช้ Active Directory Certificate Services (AD CS) บน Windows Server
ก่อนเริ่มต้น ต้องแน่ใจว่าระบบของคุณมีองค์ประกอบต่อไปนี้ครบถ้วน:
- Active Directory Domain Services (AD DS): ติดตั้งและทำงานได้อย่างสมบูรณ์
- Active Directory Certificate Services (AD CS): ติดตั้ง Role นี้และตั้งค่าเป็น Enterprise CA (Certificate Authority) เรียบร้อยแล้ว
- Network Policy Server (NPS): ติดตั้ง Role นี้บนเซิร์ฟเวอร์ (อาจจะเป็นเครื่องเดียวกับ CA หรือคนละเครื่องก็ได้)
เราจะสร้าง Template ที่จำเป็น 2 ประเภท คือสำหรับ RADIUS Server และสำหรับ Client
Template นี้ใช้สำหรับให้ NPS Server ยืนยันตัวตนกับเครื่องลูกข่าย
- บนเซิร์ฟเวอร์ที่ติดตั้ง AD CS, เปิด Certificate Authority (จาก Server Manager > Tools)
- คลิกขวาที่โฟลเดอร์
Certificate Templates
และเลือก Manage - ในหน้าต่าง
Certificate Templates Console
, ค้นหา Template ชื่อ RAS and IAS Server - คลิกขวาที่ RAS and IAS Server และเลือก Duplicate Template
- ตั้งค่าในแท็บต่างๆ ดังนี้:
- แท็บ General:
- Template display name:
802.1X RADIUS Server
(หรือชื่ออื่นที่เข้าใจง่าย) - Validity period:
2 years
(แนะนำ)
- Template display name:
- แท็บ Request Handling:
- (แนะนำ) ติ๊กถูกที่
Allow private key to be exported
เพื่อความสะดวกในการสำรองข้อมูลหรือย้ายเซิร์ฟเวอร์
- (แนะนำ) ติ๊กถูกที่
- แท็บ Subject Name:
- เลือก Build from this Active Directory information
- Subject name format: เลือก DNS name
- แท็บ Security:
- คลิก Add... และเพิ่มกลุ่ม
RAS and IAS Servers
(หรือเพิ่ม Computer Account ของ NPS Server โดยตรง) - เลือกกลุ่มที่เพิ่มเข้ามา แล้วให้สิทธิ์ (Allow)
Read
และEnroll
- คลิก Add... และเพิ่มกลุ่ม
- แท็บ Extensions:
- ตรวจสอบว่าใน Application Policies มี
Server Authentication
อยู่
- ตรวจสอบว่าใน Application Policies มี
- แท็บ General:
- คลิก Apply และ OK
Template นี้ใช้สำหรับแจกจ่ายให้เครื่องลูกข่ายใน Domain โดยอัตโนมัติ (ปลอดภัยที่สุด)
- ในหน้าต่าง
Certificate Templates Console
เดิม, ค้นหา Template ชื่อ Workstation Authentication - คลิกขวาที่ Workstation Authentication และเลือก Duplicate Template
- ตั้งค่าในแท็บต่างๆ ดังนี้:
- แท็บ General:
- Template display name:
802.1X Client Authentication
- Template display name:
- แท็บ Request Handling:
-
สำคัญ: ไม่ต้องติ๊ก
Allow private key to be exported
เพื่อความปลอดภัยสูงสุด ป้องกันการคัดลอก Certificate ไปยังเครื่องที่ไม่ได้รับอนุญาต
-
- แท็บ Subject Name:
- เลือก Build from this Active Directory information
- Subject name format: เลือก DNS name
- แท็บ Security:
- คลิก Add... และเพิ่มกลุ่ม
Domain Computers
- เลือกกลุ่ม
Domain Computers
และให้สิทธิ์ (Allow)Read
,Enroll
, และAutoenroll
สำคัญ: การให้สิทธิ์
Autoenroll
เป็นหัวใจสำคัญที่ทำให้เครื่องลูกข่ายได้รับ Certificate โดยอัตโนมัติผ่าน Group Policy - คลิก Add... และเพิ่มกลุ่ม
- แท็บ Extensions:
- ตรวจสอบว่าใน Application Policies มี
Client Authentication
อยู่
- ตรวจสอบว่าใน Application Policies มี
- แท็บ General:
- คลิก Apply และ OK
หลังจากสร้าง Template แล้ว ต้องสั่งให้ CA เริ่มออก Certificate ตาม Template เหล่านี้
- กลับไปที่หน้าต่างหลักของ Certificate Authority
- คลิกขวาที่โฟลเดอร์
Certificate Templates
-> New -> Certificate Template to Issue - ในหน้าต่างที่ปรากฏขึ้น, เลือก Template ทั้ง 2 อันที่เราเพิ่งสร้าง:
802.1X RADIUS Server
802.1X Client Authentication
- คลิก OK
- บน NPS Server, เปิด MMC โดยกด
Win + R
พิมพ์mmc
แล้ว Enter - ไปที่ File > Add/Remove Snap-in...
- เลือก Certificates -> Add -> เลือก Computer account -> Next -> Finish -> OK
- ในหน้าต่าง MMC, ขยาย Certificates (Local Computer) -> Personal
- คลิกขวาที่โฟลเดอร์ Certificates -> All Tasks -> Request New Certificate...
- คลิก Next สองครั้ง (เลือก Active Directory Enrollment Policy)
- ติ๊กเลือก Template
802.1X RADIUS Server
ที่เราสร้างไว้ - คลิก Enroll
- เปิด Group Policy Management
- สร้าง GPO ใหม่ (หรือแก้ไข GPO ที่มีอยู่) ที่ลิงก์ไปยัง OU ที่มี Computer Accounts ของเครื่องลูกข่าย
- แก้ไข GPO นั้น และไปที่ Path:
Computer Configuration -> Policies -> Windows Settings -> Security Settings -> Public Key Policies
- ในหน้าต่างด้านขวา, ดับเบิลคลิกที่ Certificate Services Client - Auto-Enrollment
- ตั้งค่าดังนี้:
- Configuration Model:
Enabled
- ติ๊กถูกที่
Renew expired certificates, update pending certificates, and remove revoked certificates
- ติ๊กถูกที่
Update certificates that use certificate templates
- Configuration Model:
- คลิก Apply และ OK
หลังจากนั้น เมื่อเครื่อง Client ทำการ gpupdate /force
หรือมีการ Restart ก็จะได้รับ Certificate 802.1X Client Authentication
โดยอัตโนมัติ
ใช้สำหรับอุปกรณ์นอกโดเมน (Non-Domain Joined) หรืออุปกรณ์พิเศษ (BYOD, IoT)
Best Practice: ควรสร้าง Template ใหม่สำหรับกรณีนี้โดยเฉพาะ อย่าแก้ไข Template หลักที่ใช้กับเครื่องในโดเมน
- สร้าง Template ใหม่: ทำซ้ำขั้นตอนที่ 2.2 แต่ตั้งชื่อว่า
802.1X Manual Install
- ตั้งค่าให้ Export ได้: ในแท็บ Request Handling ของ Template ใหม่นี้ ให้ติ๊กถูกที่
Allow private key to be exported
- ออก Certificate: ทำการ Issue Template ใหม่นี้ตามขั้นตอนที่ 3
- ร้องขอและ Export:
- จากเครื่องในโดเมน, ใช้
certlm.msc
ร้องขอ Certificate จาก Template802.1X Manual Install
- หลังจากได้รับแล้ว ให้คลิกขวาที่ Certificate -> All Tasks -> Export...
- ใน Wizard ให้เลือก Yes, export the private key
- เลือก Format เป็น .PFX, ตั้งรหัสผ่านที่คาดเดายาก
- จากเครื่องในโดเมน, ใช้
- นำไปติดตั้ง: นำไฟล์
.pfx
ที่ได้ไปติดตั้งบนอุปกรณ์เป้าหมาย โดยจะต้องใส่รหัสผ่านที่ตั้งไว้