PHP mysqli ssl_set () फ़ंक्शन
उदाहरण - वस्तु उन्मुख शैली
एक एसएसएल कनेक्शन बनाएं:
<?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 () फ़ंक्शन का उपयोग किया जाता है। हालाँकि, यह फ़ंक्शन तब तक कुछ नहीं करता जब तक कि OpenSSL समर्थन सक्षम न हो।
नोट: इस फ़ंक्शन को real_connect() से पहले कॉल किया जाना चाहिए ।
नोट: MySQL नेटिव ड्राइवर PHP 5.3.3 से पहले एसएसएल का समर्थन नहीं करता है। PHP 5.3+ से Microsoft Windows पर MySQL नेटिव ड्राइवर डिफ़ॉल्ट रूप से सक्षम है।
वाक्य - विन्यास
वस्तु उन्मुख शैली:
$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 |
टेक्निकल डिटेल
प्रतिलाभ की मात्रा: | अटल सत्य। यदि एसएसएल सेटअप गलत है, तो जब आप कनेक्ट करने का प्रयास करेंगे तो real_connect() एक त्रुटि लौटाएगा |
---|---|
पीएचपी संस्करण: | 5+ |
उदाहरण - प्रक्रियात्मक शैली
एक एसएसएल कनेक्शन बनाएं:
<?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 संदर्भ