နားလည်ထားရမယ့် အချက်
HTTP ဆိုတာ browser နဲ့ server တို့ request/response ဖလှယ်ဖို့ သုံးတဲ့ protocol ပါ။ Plain HTTP က စကားဝိုင်းကို ဖတ်နိုင်တဲ့ text အဖြစ် ပို့လို့ network path ပေါ်ရှိ ဘယ်သူမဆို ဖတ်နိုင်ပါတယ်။
HTTPS ကတော့ HTTP ကို TLS ပေါ်မှာ ထပ်ထားတဲ့ protocol ဖြစ်ပြီး connection ကို encrypt လုပ်ပေးတယ်။ Password, payment detail, personal data တွေ browser နဲ့ server ကြား သွားနေချိန် ချောင်းနားထောင်နေသူတွေအတွက် ဖတ်မရအောင် ကာကွယ်ပေးနိုင်လို့ ဒါက အရေးကြီးတယ်။
Modern hosting platform အများစုက Let's Encrypt လို free service ကနေ certificate ကို automatic issue/renew လုပ်ပေးကြပါတယ် — မှန်ကန်စွာ configure လုပ်ထားတဲ့ deployment မှာ HTTPS ကို လက်တွေ့ အလကားနီးပါး ရရှိပါတယ်။ ဒီ lesson က TLS handshake mechanics ကို ဒီ site ရဲ့ Networking tutorial ဆီ ညွှန်းထားပါတယ်။
HTTP VS HTTPS
-------------
HTTP (plain text)
Browser ------ readable data ------> Server
(anyone on the network could read it)
HTTPS (encrypted with TLS)
Browser ==== encrypted data ====> Server
(only browser and server can read it)လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်
အောက်က isSecure function က URL string တစ်ခုကို ယူပြီး https colon slash slash နဲ့ စတယ်လား စစ်ကာ HTTPS သုံးမသုံး ပြန်ပေးပါတယ်။ Browser context မှာ ဘေးကင်းအောင် ရေးထားတာလည်း သတိပြုပါ — URL ဘာမှ မပေးဘဲ window object ရှိနေရင် (ဆိုလိုတာက browser အစစ်ထဲမှာ code က run နေတာ) crash မဖြစ်ဘဲ page ကိုယ်တိုင်ရဲ့ address ကို ပြန်ဖတ်ပါတယ်။
ဒီလို check ဟာ application အစစ်တွေမှာ တကယ် အသုံးဝင်ပါတယ် — ဥပမာ user တစ်ယောက် site ရဲ့ insecure version ပေါ်ရောက်နေရင် သတိပေးခြင်း (သို့) auto-redirect လုပ်ပေးခြင်းအတွက်ပါ။ Plain HTTP ဥပမာ၊ secure HTTPS domain၊ path ပါတဲ့ secure HTTPS URL တို့နဲ့ run ကြည့်တာက protocol နှစ်ခုကြားမှာ boolean flip ကို ရှင်းရှင်းလင်းလင်း ပြပါတယ်။
ဒီ function ဟာ ဘာကို ဘာမှ ပြောမပေးနိုင်ဘူးဆိုတာလည်း သတိပြုပါ — အဲဒီ HTTPS URL ရဲ့ နောက်ကွယ်က server မှာ password ကောင်းလား၊ software patch လုပ်ထားလား၊ database လုံခြုံလား ဘာမှ မသိပါဘူး။ Connection ကိုယ်တိုင် encrypted ဖြစ်မယ်လား ဆိုတဲ့ narrow ပေမယ့် တကယ် အရေးကြီးတဲ့ fact တစ်ခုကိုပဲ report လုပ်ပေးတာပါ — ဒါက ဒီ lesson ရဲ့ HTTPS သတိပေးချက် ညွှန်ပြနေတဲ့ boundary အတိအကျပါပဲ။
HTTPS != 100% Secure
HTTPS က data ကို network ပေါ်ရွေ့နေချိန်သာ ကာကွယ်ပေးတာပါ။ Application ထဲက bug, database ပေါက်ကြားမှု, password အားနည်းချက်တွေကို ဘာမှ ကာကွယ်မပေးပါ — site တစ်ခုဟာ HTTPS အပြည့်နဲ့ application level မှာ လုံခြုံမှု မရှိနိုင်ပါဘူး။
အတူတူ စမ်းရေးကြည့်မယ်
function isSecure(url) {
if (typeof window !== "undefined" && !url) {
url = window.location.href;
}
return url.startsWith("https://");
}
const urls = [
"http://example.com",
"https://thutatech.com",
"https://learn.thutatech.com/path"
];
for (const url of urls) {
console.log(`${url} -> secure: ${isSecure(url)}`);
}http://example.com -> secure: false
https://thutatech.com -> secure: true
https://learn.thutatech.com/path -> secure: true၅ မိနစ် စမ်းကြည့်
urls array ထဲကို "ftp://files.thutatech.com" ကို ထပ်ထည့်ပြီး run ပါ — isSecure() က HTTPS မဟုတ်တဲ့ protocol တွေ အားလုံးကို false ပြန်ပေးတာကို confirm လုပ်ပါ၊ HTTP ဖြစ်ချင်မှသာ false ပြန်တာ မဟုတ်ကြောင်း သတိပြုပါ။
သတိလေးတစ်ချက်
HTTPS ရှိရင် site အားလုံး လုံခြုံပြီလို့ ယူဆခြင်း — application-level bug/password/database ပြဿနာတွေကို လျစ်လျူရှုမိခြင်း
Certificate ကို manual ရယူ/renew လုပ်ရမယ်လို့ ထင်ခြင်း — modern platform အများစုက automate လုပ်ပေးနေတာကို မသိခြင်း
MDN Glossary: HTTPS — Cloud & Deployment