Ticket #21663: ssl.patch
File ssl.patch, 4.0 KB (added by , 11 years ago) |
---|
-
inc/interface-wp-db-driver.php
4 4 public function escape( $string ); 5 5 public function get_error_message(); 6 6 public function flush(); 7 public function connect( $host, $user, $pass, $port = 3306 );7 public function connect( $host, $user, $pass, $port = 3306, $options = array() ); 8 8 public function select( $name ); 9 9 public function query( $query ); 10 10 public function load_col_info(); -
db.php
198 198 199 199 $this->is_mysql = true; 200 200 201 $new_link = defined( 'MYSQL_NEW_LINK' ) ? MYSQL_NEW_LINK : true; 202 $client_flags = defined( 'MYSQL_CLIENT_FLAGS' ) ? MYSQL_CLIENT_FLAGS : 0; 201 $options = array(); 202 $options['key'] = defined( 'DB_SSL_KEY' ) ? DB_SSL_KEY : null; 203 $options['cert'] = defined( 'DB_SSL_CERT' ) ? DB_SSL_CERT : null; 204 $options['ca'] = defined( 'DB_SSL_CA' ) ? DB_SSL_CA : null; 205 $options['ca_path'] = defined( 'DB_SSL_CA_PATH' ) ? DB_SSL_CA_PATH : null; 206 $options['cipher'] = defined( 'DB_SSL_CIPHER' ) ? DB_SSL_CIPHER : null; 203 207 204 208 $host = $this->dbhost; 205 209 $port = 3306; … … 207 211 list( $host, $port ) = explode( ':', $this->dbhost ); 208 212 } 209 213 210 if ( !$this->dbh->connect( $host, $this->dbuser, $this->dbpassword, $port ) ) {214 if ( !$this->dbh->connect( $host, $this->dbuser, $this->dbpassword, $port, $options ) ) { 211 215 wp_load_translations_early(); 212 216 $this->bail( sprintf( __( " 213 217 <h1>Error establishing a database connection</h1> -
drivers/mysqli.php
62 62 * Connect to database 63 63 * @return bool 64 64 */ 65 public function connect( $host, $user, $pass, $port = 3306 ) {65 public function connect( $host, $user, $pass, $port = 3306, $options = array() ) { 66 66 $this->dbh = new mysqli( $host, $user, $pass, '', $port ); 67 68 if ( !empty( $options['key'] ) && !empty( $options['cert'] ) && !empty( $options['ca'] ) ) { 69 $this->dbh->ssl_set( 70 $options['key'], 71 $options['cert'], 72 $options['ca'], 73 $options['ca_path'], 74 $options['cipher'] 75 ); 76 } 77 67 78 return ( !mysqli_connect_error() ); 68 79 } 69 80 -
drivers/mysql.php
62 62 * Connect to database 63 63 * @return bool 64 64 */ 65 public function connect( $host, $user, $pass, $port = 3306 ) {65 public function connect( $host, $user, $pass, $port = 3306, $options = array() ) { 66 66 67 67 $new_link = defined( 'MYSQL_NEW_LINK' ) ? MYSQL_NEW_LINK : true; 68 68 $client_flags = defined( 'MYSQL_CLIENT_FLAGS' ) ? MYSQL_CLIENT_FLAGS : 0; -
drivers/pdo_mysql.php
75 75 * Connect to database 76 76 * @return bool 77 77 */ 78 public function connect( $host, $user, $pass, $port = 3306 ) {78 public function connect( $host, $user, $pass, $port = 3306, $options = array() ) { 79 79 $dsn = sprintf( 'mysql:host=%1$s;port=%2$d', $host, $port ); 80 80 try { 81 $this->dbh = new PDO( $dsn, $user, $pass ); 81 $pdo_options = array(); 82 $pdo_options[PDO::MYSQL_ATTR_SSL_KEY] = $options['key']; 83 $pdo_options[PDO::MYSQL_ATTR_SSL_CERT] = $options['cert']; 84 $pdo_options[PDO::MYSQL_ATTR_SSL_CA] = $options['ca']; 85 $pdo_options[PDO::MYSQL_ATTR_SSL_CAPATH] = $options['ca_path']; 86 $pdo_options[PDO::MYSQL_ATTR_SSL_CIPHER] = $options['cipher']; 87 $pdo_options = array_filter( $pdo_options ); 88 89 $this->dbh = new PDO( $dsn, $user, $pass, $pdo_options ); 82 90 $this->dbh->setAttribute ( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); 83 91 } catch ( Exception $e ) { 84 92 return false;