PHP mysqli_ssl_set() Function

Definition

PHP mysqli_ssl_set() Function creates an SSL connection.

Syntax

PHP mysqli_ssl_set() Function has the following syntax.

mysqli_ssl_set(connection,key,cert,ca,capath,cipher);

Parameter

ParameterIs RequiredDescription
connectionRequired.MySQL connection to use
keyRequired.Path name to the key file
certRequired.Path name to the certificate file
caRequired.Path name to the certificate authority file
capathRequired.Pathname to a directory that contains trusted SSL CA certificates in PEM format
cipherRequired.A list of allowable ciphers for SSL encryption

Return

Returns TRUE on success or FALSE on failure.

Example

The mysqli_ssl_set() function establishes secure connections using SSL for the enabled OpenSSL support. This function must be called before mysqli_real_connect().


<?php// w  ww .j a  v a2s .  c  om
$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());
}


mysqli_close($con);
?>




















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions