เข้ารหัสด้วย TLS และตรวจสอบใบรับรอง
ปกป้องข้อมูลระหว่างส่งและยืนยันความน่าเชื่อถือของเซิร์ฟเวอร์
เข้ารหัสด้วย TLS และตรวจสอบใบรับรอง เป็นบทเรียน Arduino & IoT Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Arduino & IoT Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Arduino & IoT Academy มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Why Encrypt at All
Data crossing WiFi and the internet passes many hands. Encryption scrambles it so only the intended server can read your readings. 🔒
Meet TLS
TLS is the layer that turns HTTP into HTTPS. It encrypts the channel between your device and a server so eavesdroppers see only noise.
The Handshake
Before any data flows, the two sides agree on keys in a handshake. This setup proves the server's identity and locks in a shared secret.
What a Certificate Proves
A server presents a certificate signed by a trusted authority. It proves the server really is who it claims to be, not an imposter.
Encryption Without Verification
Encrypting but skipping checks is dangerous. Without verification, an attacker can sit in the middle, hold the keys, and read everything.
The Man in the Middle
A man-in-the-middle impersonates the server and relays your traffic. Verifying the certificate is exactly what stops this attack cold.
Use WiFiClientSecure
On the ESP32, WiFiClientSecure handles TLS connections. It is the secure cousin of the plain client you used for HTTP.
#include <WiFiClientSecure.h>
WiFiClientSecure client;Pin the Root CA
Give your device the server's root certificate so it can verify trust. This pinned CA is how the board knows the server is genuine.
client.setCACert(root_ca); // verify the server against this trusted CANever Skip the Check
Calling setInsecure turns off all verification. setInsecure is fine for a quick test but should never reach a shipped product.
client.setInsecure(); // DANGER: trusts any server, use only for testingCertificates Expire
Every certificate has an expiry date, so verification needs the right time. A device with the wrong clock may wrongly reject a valid server.
Encrypt MQTT Too
TLS is not just for HTTPS. Point your MQTT client at a TLS broker port like 8883 to protect your pub/sub messages the same way.
Quick Check
Encryption alone is not enough. What else matters?
Recap
TLS encrypts traffic and certificates prove identity. Use WiFiClientSecure, pin a trusted CA, keep the clock right, and never ship setInsecure. 🛡️
คำถามที่พบบ่อย
บทเรียน “เข้ารหัสด้วย TLS และตรวจสอบใบรับรอง” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “เข้ารหัสด้วย TLS และตรวจสอบใบรับรอง” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Arduino & IoT Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Arduino & IoT Academy มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “เข้ารหัสด้วย TLS และตรวจสอบใบรับรอง”
ปกป้องข้อมูลระหว่างส่งและยืนยันความน่าเชื่อถือของเซิร์ฟเวอร์ คุณปฏิบัติ Arduino & IoT Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Arduino & IoT Academy หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Arduino & IoT Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน
บทเรียน “เข้ารหัสด้วย TLS และตรวจสอบใบรับรอง” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Arduino & IoT Academy นี้ได้ไหม
ได้ บทเรียน Arduino & IoT Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- ช่องทางโจมตี IoT ที่พบบ่อย
- เก็บความลับให้พ้นจากโค้ด
- เข้ารหัสด้วย TLS และตรวจสอบใบรับรอง
- ลงลายเซ็นและล็อกเฟิร์มแวร์