Skip to main content

Posts

Showing posts from January, 2022

Connecting to mysql with TLS 1.2 SSL encrypted connection

In order to be able to connect to MySQL remote server using encrypted connection overt TLS1.2 you will need a .pem certificate of CA.  You can obtain the certificate here: https://dl.cacerts.digicert.com/DigiCertGlobalRootCA.crt.pem (DigiCertGlobalRootCA.crt.pem) Read more here: https://docs.microsoft.com/en-us/azure/mysql/flexible-server/how-to-connect-tls-ssl Here is a PHP sample for connection with SSL to MySQL encrypted connection on TLS1.2: self::$mysqli = mysqli_init(); //self::$mysqli->options(MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, true); self::$mysqli->ssl_set(NULL, NULL, "DigiCertGlobalRootCA.crt.pem", NULL, NULL); self::$mysqli->real_connect(host', 'username', 'password', 'database'); // , 3306, MYSQLI_CLIENT_SSL); //self::$mysqli = new mysqli('hots', 'username', 'password', 'database');    self::$mysqli->set_charset('utf8'); return self::$mysqli; Here is the full certificate for M