mysqli_real_connect
( ) function.
The DigiCertGlobalRootCA.crt.pem
file is a text-based file that contains a certificate, a private key, and any associated certificates.
The PEM file format is used by many different applications, including OpenSSL, PuTTY, and Thunderbird.
A CRT file is a binary file that contains only the certificate.
By default, Azure Database for MySQL enforces SSL connections between your server and your client applications to protect against MITM (man in the middle) attacks.
The syntax is as follows:
|
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. |
<html><body> <?php $username = "wenchen"; $database = "wenchen"; $host = "undcemmysql.mysql.database.azure.com"; $password = ""; // Initializing MySQLi $conn = mysqli_init( ); // Creating an SSL connection mysqli_ssl_set( $conn, NULL, NULL, "DigiCertGlobalRootCA.crt.pem", NULL, NULL ); // Opening a new connection to the MySQL server mysqli_real_connect( $conn, $host, $username, $password, $database, 3306 ); // Connecting to the database if ( $conn->connect_errno ) die( 'Failed to connect to MySQL: ' . $conn->connect_error ); else echo "Successfully connect to MySQL!"; // Closing the database connection $conn->close( ); ?> </body></html> |
|
|
|
My wife left me because I am insecure. No wait, she’s back. She just went to get coffee. |