# คู่มือการต่ออายุ Wildcard Certificate **โรงเรียนสาธิตจุฬาลงกรณ์มหาวิทยาลัย ฝ่ายมัธยม** **คู่มือปฏิบัติการ IT** --- ## ภาพรวม คู่มือนี้ให้คำแนะนำทีละขั้นตอนสำหรับการต่ออายุ wildcard certificate ประจำปีที่ใช้ในโครงสร้างเครือข่ายของโรงเรียน Certificate นี้ต้องต่ออายุทุกปีและต้องติดตั้งในสองตำแหน่งที่สำคัญ ## ข้อมูล Certificate - **ผู้ให้บริการ**: https://www.hostneverdie.com/ - **วันหมดอายุปัจจุบัน**: 21 พฤศจิกายน 2025 - **กำหนดการต่ออายุ**: ทุกปี (ขึ้นอยู่กับเวลาที่ทำการต่ออายุ) - **ประเภท Certificate**: Wildcard SSL Certificate ## ข้อกำหนดเบื้องต้น - สิทธิ์ผู้ดูแลระบบในการเข้าถึง FortiGate (10.0.98.1) - สิทธิ์ SSH/ผู้ดูแลระบบในการเข้าถึง Reverse Proxy server (10.3.2.10) - ไฟล์ certificate ใหม่ (.crt และ .key) ที่ได้จาก hostneverdie.com --- ## ส่วนที่ 1: การจัดหา Certificate ### ขั้นตอนที่ 1: รับ Certificate ใหม่จากผู้ให้บริการ 1. ติดต่อผู้ให้บริการ hostneverdie.com เพื่อขอต่ออายุ certificate 2. รอรับไฟล์ certificate ใหม่ทางอีเมล์: - ไฟล์ Certificate (.crt) - ไฟล์ Private key (.key) ### ขั้นตอนที่ 2: ตรวจสอบไฟล์ Certificate 1. ตรวจสอบให้แน่ใจว่าคุณมีทั้งสองไฟล์: - `domain.crt` (ไฟล์ certificate) - `domain.key` (ไฟล์ private key) 2. จดบันทึกวันหมดอายุใหม่สำหรับเอกสาร --- ## ส่วนที่ 2: การติดตั้งใน FortiGate (10.0.98.1) ### ขั้นตอนที่ 3: เข้าถึง FortiGate Management Interface 1. เปิดเว็บเบราว์เซอร์และไปที่: `https://10.0.98.1` 2. เข้าสู่ระบบด้วยข้อมูลประจำตัวผู้ดูแลระบบ ![FortiGate Login Screen](photos/common/fortigate_login.png) 3. ตรวจสอบให้แน่ใจว่าคุณอยู่ใน **root VDOM** (ตรวจสอบมุมบนขวา) ![FortiGate VDOM Root](photos/common/fortigate_vdom_root.png) ### ขั้นตอนที่ 4: นำเข้า Certificate ใหม่ 1. ไปที่ **System** → **Certificates** ![FortiGate System Menu](photos/cert_renew/fgt_menu_certificate.png) 2. คลิกปุ่ม **Create/Import** ![FortiGate Create/Import Certificate](photos/cert_renew/fgt_create_import_cert.png) 3. เลือก **Certificate** จาก dropdown ![FortiGate Import Certificate](photos/cert_renew/fgt_import_certificate.png) 4. เลือก **Import Certificate** 5. ใน Certificate import dialog: - คลิก **Browse** ข้างช่อง **Certificate** - เลือกไฟล์ `.crt` ของคุณ - คลิก **Browse** ข้างช่อง **Private Key** - เลือกไฟล์ `.key` ของคุณ ![FortiGate Upload Certificate](photos/cert_renew/fgt_upload_cert.png) 6. คลิก **Create** เพื่อนำเข้า certificate ### ขั้นตอนที่ 5: อัปเดต Authentication Settings 1. ไปที่ **User & Authentication** → **Authentication Settings** 2. ในส่วน **Certificate** เลือก certificate ที่เพิ่งนำเข้ามา ![FortiGate User Authentication Certificate](photos/cert_renew/fgt_user_auth_cert.png) 3. คลิก **Apply** เพื่อบันทึกการเปลี่ยนแปลง ### ขั้นตอนที่ 6: อัปเดต SSL/SSH Inspection Profile **⚠️ สำคัญ: ลบ certificate เก่าออกก่อนที่จะเพิ่ม certificate ใหม่** 1. ไปที่ **Security Profiles** → **SSL/SSH Inspection** 2. ค้นหาและแก้ไข profile **"reverse-proxy"** ![FortiGate Reverse Proxy Certificate](photos/cert_renew/fgt_reverse_proxy_cert.png) 3. ในส่วน **Server Certificate**: - **ขั้นแรก**: ลบ certificate เก่าโดยคลิกปุ่ม **X** หรือ **Remove** - **จากนั้น**: เลือก certificate ที่เพิ่งนำเข้ามา ![FortiGate SSL/SSH Server Certificate](photos/cert_renew/fgt_ssl_ssh_server_cert.png) 4. คลิก **OK** เพื่อบันทึกการเปลี่ยนแปลงของ profile --- ## ส่วนที่ 3: การติดตั้งใน Reverse Proxy (10.3.2.10) ### ขั้นตอนที่ 7: เข้าถึง Reverse Proxy Server 1. เชื่อมต่อไปยัง reverse proxy server ผ่าน SSH: ```bash ssh cud@10.3.2.10 ``` 2. ไปยัง certificate directory: ```bash cd /etc/nginx/certs/ ``` ### ขั้นตอนที่ 8: สำรองข้อมูล Certificate ที่มีอยู่ 1. สร้างการสำรองข้อมูลของ certificate ปัจจุบัน: ```bash sudo cp satitm.crt satitm.crt.backup.$(date +%Y%m%d) sudo cp satitm.key satitm.key.backup.$(date +%Y%m%d) ``` 2. แสดงรายการไฟล์เพื่อตรวจสอบการสร้างข้อมูลสำรอง: ```bash ls -la ``` ### ขั้นตอนที่ 8: อัปโหลดไฟล์ Certificate ด้วย WinSCP 1. ดาวน์โหลดและติดตั้ง WinSCP จาก https://winscp.net/eng/downloads.php (หากยังไม่ได้ติดตั้ง) 2. เปิดโปรแกรม WinSCP ![WinSCP Main Window](photos/winscp/main_window.png) 3. สร้างการเชื่อมต่อใหม่: - **Host name**: 10.3.2.10 - **User name**: cud - **Password**: [รหัสผ่าน] - **Port**: 22 ![WinSCP Login Dialog](photos/winscp/login.png) 4. คลิก **Login** เพื่อเชื่อมต่อ 5. หากเป็นการเชื่อมต่อครั้งแรก จะมีป๊อปอัปขอยืนยัน SSH key คลิก **Accept** เพื่อยอมรับ (ขั้นตอนนี้เป็นทางเลือก) ![WinSCP Accept SSH Key](photos/winscp/accept_ssh_key.png) ![WinSCP Connected Interface](photos/winscp/main_window_connected.png) 6. ในหน้าต่าง WinSCP: - **ด้านซ้าย**: ไฟล์ในเครื่อง Windows ของคุณ - **ด้านขวา**: ไฟล์ในเซิร์ฟเวอร์ Linux 7. นำทางไปยังโฟลเดอร์ที่มีไฟล์ certificate ใหม่ (ด้านซ้าย) 8. นำทางไปยังโฟลเดอร์ home directory เช่น `/home/cud/` (ด้านขวา) 9. ลากไฟล์ certificate (.crt) และ private key (.key) จากด้านซ้ายไปด้านขวา 10. ตรวจสอบว่าไฟล์ถูกอัปโหลดสำเร็จแล้ว ### ขั้นตอนที่ 9: ติดตั้งไฟล์ Certificate ใหม่ 1. คัดลอกไฟล์ certificate จาก `/home/cud/` ไปยังตำแหน่งที่ถูกต้อง: **หมายเหตุ**: ชื่อไฟล์ที่คุณได้รับอาจแตกต่างกัน เพื่อความสะดวกในการคัดลอกคำสั่ง ควรเปลี่ยนชื่อไฟล์ให้เป็น `certificate.crt` และ `private.key` ก่อน ```bash sudo cp /home/cud/certificate.crt /etc/nginx/certs/satitm.crt sudo cp /home/cud/private.key /etc/nginx/certs/satitm.key ``` 2. กำหนดสิทธิ์ที่ถูกต้อง: ```bash sudo chmod 644 /etc/nginx/certs/satitm.crt sudo chmod 600 /etc/nginx/certs/satitm.key sudo chown root:root /etc/nginx/certs/satitm.* ``` ### ขั้นตอนที่ 10: รีสตาร์ท Nginx Service 1. ทดสอบการกำหนดค่า Nginx: ```bash sudo nginx -t ``` ผลลัพธ์ที่คาดหวัง: ``` nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful ``` 2. หากการทดสอบการกำหนดค่าผ่าน ให้รีสตาร์ท Nginx: ```bash sudo service nginx restart ``` 3. ตรวจสอบว่า Nginx กำลังทำงาน: ```bash sudo service nginx status ``` ผลลัพธ์ที่คาดหวัง (ดูที่บรรทัด Active): ``` ● nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2025-08-27 06:04:11 UTC; 4 days ago Docs: man:nginx(8) Main PID: 11527 (nginx) Tasks: 49 (limit: 4548) Memory: 129.1M ``` **สำคัญ**: ตรวจสอบให้แน่ใจว่าบรรทัด "Active" แสดงสถานะ "active (running)" --- ## ส่วนที่ 4: การตรวจสอบและทดสอบ ### ขั้นตอนที่ 11: ตรวจสอบการติดตั้ง Certificate 1. **ทดสอบ FortiGate Certificate**: - เข้าถึง web interface ของ FortiGate - ตรวจสอบว่าเบราว์เซอร์แสดง certificate ที่ถูกต้อง - ตรวจสอบวันหมดอายุในรายละเอียด certificate ของเบราว์เซอร์ 2. **ทดสอบ Reverse Proxy Certificate**: - เข้าถึงบริการผ่าน reverse proxy - ตรวจสอบ SSL certificate ในเบราว์เซอร์ - ตรวจสอบรายละเอียด certificate สำหรับวันหมดอายุที่ถูกต้อง ### ขั้นตอนที่ 12: อัปเดตเอกสาร 1. บันทึกวันหมดอายุ certificate ใหม่ 2. อัปเดตระบบตรวจสอบ/ติดตาม certificate 3. ตั้งการแจ้งเตือนในปฏิทินสำหรับการต่ออายุปีหน้า (แนะนำ 30-60 วันก่อนหมดอายุ) --- ## การแก้ไขปัญหา ### ปัญหาที่พบบ่อย **การนำเข้า Certificate ใน FortiGate ล้มเหลว** - ตรวจสอบรูปแบบไฟล์ certificate และ key - ตรวจสอบให้แน่ใจว่าคุณอยู่ใน root VDOM - ตรวจสอบว่า certificate และ private key ตรงกัน **Nginx ไม่สามารถเริ่มต้นหลังจากติดตั้ง Certificate** - รัน `sudo nginx -t` เพื่อตรวจสอบ syntax ของการกำหนดค่า - ตรวจสอบสิทธิ์ไฟล์ certificate (644 สำหรับ .crt, 600 สำหรับ .key) - ตรวจสอบว่าไฟล์ certificate ไม่เสียหาย **Certificate แสดงเป็น Invalid ในเบราว์เซอร์** - ตรวจสอบว่าการติดตั้ง certificate สำเร็จแล้ว - ล้าง cache และ cookies ของเบราว์เซอร์ - ตรวจสอบวันหมดอายุและระยะเวลาที่ certificate ใช้ได้ ### การคืนค่าในกรณีฉุกเฉิน หากเกิดปัญหาหลังจากการติดตั้ง certificate: **การคืนค่า FortiGate**: 1. เปลี่ยนกลับไปใช้ certificate ก่อนหน้าใน SSL/SSH Inspection profile 2. อัปเดต Authentication Settings เพื่อใช้ certificate ก่อนหน้า **การคืนค่า Reverse Proxy**: 1. กู้คืน certificate สำรอง: ```bash sudo cp satitm.crt.backup.YYYYMMDD satitm.crt sudo cp satitm.key.backup.YYYYMMDD satitm.key ``` 2. รีสตาร์ท Nginx: `sudo service nginx restart` --- ## ข้อมูลการติดต่อ สำหรับความช่วยเหลือในการต่ออายุ certificate: - **ผู้ให้บริการ Certificate**: https://www.hostneverdie.com/ - **ติดต่อฉุกเฉิน**: ศิวัช ศิริชัย 086-789-5193 --- **เวอร์ชันเอกสาร**: 1.0 **อัปเดตล่าสุด**: 31 สิงหาคม 2025 **ทบทวนครั้งต่อไป**: 31 สิงหาคม 2026