PHP mysqli ssl_set() လုပ်ဆောင်ချက်
ဥပမာ - Object Oriented စတိုင်
SSL ချိတ်ဆက်မှု ဖန်တီးပါ-
<?php
$mysqli = mysqli_init();
if (!$mysqli) {
die("mysqli_init failed");
}
$mysqli -> ssl_set("key.pem", "cert.pem", "cacert.pem", NULL, NULL);
if (!$mysqli -> real_connect("localhost","my_user","my_password","my_db"))
{
die("Connect Error: " . mysqli_connect_error());
}
// Some queries...
$mysqli -> close();
?>
အောက်ခြေတွင် လုပ်ထုံးလုပ်နည်းပုံစံ နမူနာကိုကြည့်ပါ။
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
ssl_set() / mysqli_ssl_set() လုပ်ဆောင်ချက်ကို SSL ကို အသုံးပြု၍ လုံခြုံသောချိတ်ဆက်မှုများကို ထူထောင်ရန်အတွက် အသုံးပြုပါသည်။ သို့သော်လည်း OpenSSL ပံ့ပိုးမှုကို ဖွင့်မထားပါက ဤလုပ်ဆောင်ချက်သည် မည်သည့်အရာမှ လုပ်ဆောင်မည်မဟုတ်ပါ။
မှတ်ချက်- ဤလုပ်ဆောင်ချက်ကို real_connect() မတိုင်မီ ခေါ်ရပါမည် ။
မှတ်ချက်- MySQL Native Driver သည် PHP 5.3.3 မတိုင်မီ SSL ကို မပံ့ပိုးပါ။ MySQL Native Driver ကို PHP 5.3+ မှ Microsoft Windows တွင် မူရင်းအတိုင်း ဖွင့်ထားသည်။
အထားအသို
အရာဝတ္ထုကို ဦးတည်သည့်ပုံစံ-
$mysqli -> ssl_set(key, cert, ca, capath, cipher)
လုပ်ထုံးလုပ်နည်းပုံစံ-
mysqli_ssl_set(connection, key, cert, ca, capath, cipher)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
connection | Required. Specifies the MySQL connection to use |
key | Required. Specifies the path name to the key file |
cert | Required. Specifies the path name to the certificate file |
ca | Required. Specifies the path name to the certificate authority file |
capath | Required. Specifies the pathname to a directory that contains trusted SSL CA certificates in PEM format |
cipher | Required. Specifies a list of allowable ciphers to use for SSL encryption |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | အမြဲတမ်းအမှန်ပါ။ SSL စနစ်ထည့်သွင်းမှု မှားယွင်းနေပါက၊ သင်ချိတ်ဆက်ရန် ကြိုးစားသောအခါ တွင် real_connect() သည် အမှားအယွင်းတစ်ခု ပြန်ဖြစ်သွားပါလိမ့်မည်။ |
---|---|
PHP ဗားရှင်း- | ၅+ |
ဥပမာ- လုပ်ထုံးလုပ်နည်းပုံစံ
SSL ချိတ်ဆက်မှု ဖန်တီးပါ-
<?php
$con = mysqli_init();
if (!$con) {
die("mysqli_init failed");
}
mysqli_ssl_set($con, "key.pem", "cert.pem", "cacert.pem", NULL, NULL);
if (!mysqli_real_connect($con, "localhost", "my_user", "my_password", "my_db")) {
die("Connect Error: " . mysqli_connect_error());
}
// Some queries...
mysqli_close($con);
?>
❮ PHP MySQLi အကိုးအကား