rrichards                                Fri, 15 Apr 2011 14:24:40 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=310239

Log:
Implement FR #48587 (MySQL PDO driver doesn't support SSL connections)

Bug: http://bugs.php.net/48587 (Assigned) MySQL PDO driver doesn't support SSL 
connections
      
Changed paths:
    U   php/php-src/branches/PHP_5_3/NEWS
    U   php/php-src/branches/PHP_5_3/ext/pdo_mysql/mysql_driver.c
    U   php/php-src/branches/PHP_5_3/ext/pdo_mysql/pdo_mysql.c
    U   php/php-src/branches/PHP_5_3/ext/pdo_mysql/php_pdo_mysql_int.h
    U   php/php-src/trunk/ext/pdo_mysql/mysql_driver.c
    U   php/php-src/trunk/ext/pdo_mysql/pdo_mysql.c
    U   php/php-src/trunk/ext/pdo_mysql/php_pdo_mysql_int.h

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS   2011-04-15 14:21:20 UTC (rev 310238)
+++ php/php-src/branches/PHP_5_3/NEWS   2011-04-15 14:24:40 UTC (rev 310239)
@@ -64,6 +64,10 @@
   . Fixed bug #54167 (PDO_DBLIB returns null on SQLUNIQUE field).
     (mjh at hodginsmedia dot com, Felipe)

+- PDO MySQL driver:
+  . Implemented FR #48587 (MySQL PDO driver doesn't support SSL connections).
+    (Rob)
+
 - PDO PostgreSQL driver:
   . Fixed bug #54318 (Non-portable grep option used in PDO pgsql
     configuration). (bwalton at artsci dot utoronto dot ca)

Modified: php/php-src/branches/PHP_5_3/ext/pdo_mysql/mysql_driver.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pdo_mysql/mysql_driver.c   2011-04-15 
14:21:20 UTC (rev 310238)
+++ php/php-src/branches/PHP_5_3/ext/pdo_mysql/mysql_driver.c   2011-04-15 
14:24:40 UTC (rev 310239)
@@ -625,6 +625,9 @@
                char *default_file = NULL, *default_group = NULL;
                long compress = 0;
 #endif
+#if HAVE_MYSQL_STMT_PREPARE || PDO_USE_MYSLQND
+               char *ssl_key = NULL, *ssl_cert = NULL, *ssl_ca = NULL, 
*ssl_capath = NULL, *ssl_cipher = NULL;
+#endif
                H->buffered = pdo_attr_lval(driver_options, 
PDO_MYSQL_ATTR_USE_BUFFERED_QUERY, 1 TSRMLS_CC);

                H->emulate_prepare = pdo_attr_lval(driver_options,
@@ -709,6 +712,32 @@
                        }
                }
 #endif
+#if HAVE_MYSQL_STMT_PREPARE || PDO_USE_MYSLQND
+               ssl_key = pdo_attr_strval(driver_options, 
PDO_MYSQL_ATTR_SSL_KEY, NULL TSRMLS_CC);
+               ssl_cert = pdo_attr_strval(driver_options, 
PDO_MYSQL_ATTR_SSL_CERT, NULL TSRMLS_CC);
+               ssl_ca = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_SSL_CA, 
NULL TSRMLS_CC);
+               ssl_capath = pdo_attr_strval(driver_options, 
PDO_MYSQL_ATTR_SSL_CAPATH, NULL TSRMLS_CC);
+               ssl_cipher = pdo_attr_strval(driver_options, 
PDO_MYSQL_ATTR_SSL_CIPHER, NULL TSRMLS_CC);
+
+               if (ssl_key || ssl_cert || ssl_ca || ssl_capath || ssl_cipher) {
+                       mysql_ssl_set(H->server, ssl_key, ssl_cert, ssl_ca, 
ssl_capath, ssl_cipher);
+                       if (ssl_key) {
+                               efree(ssl_key);
+                       }
+                       if (ssl_cert) {
+                               efree(ssl_cert);
+                       }
+                       if (ssl_ca) {
+                               efree(ssl_ca);
+                       }
+                       if (ssl_capath) {
+                               efree(ssl_capath);
+                       }
+                       if (ssl_cipher) {
+                               efree(ssl_cipher);
+                       }
+               }
+#endif
        }

 #ifdef PDO_MYSQL_HAS_CHARSET

Modified: php/php-src/branches/PHP_5_3/ext/pdo_mysql/pdo_mysql.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pdo_mysql/pdo_mysql.c      2011-04-15 
14:21:20 UTC (rev 310238)
+++ php/php-src/branches/PHP_5_3/ext/pdo_mysql/pdo_mysql.c      2011-04-15 
14:24:40 UTC (rev 310239)
@@ -79,7 +79,11 @@
        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_DIRECT_QUERY", 
(long)PDO_MYSQL_ATTR_DIRECT_QUERY);
        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_FOUND_ROWS", 
(long)PDO_MYSQL_ATTR_FOUND_ROWS);
        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_IGNORE_SPACE", 
(long)PDO_MYSQL_ATTR_IGNORE_SPACE);
-
+       REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_KEY", 
(long)PDO_MYSQL_ATTR_SSL_KEY);
+       REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CERT", 
(long)PDO_MYSQL_ATTR_SSL_CERT);
+       REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CA", 
(long)PDO_MYSQL_ATTR_SSL_CA);
+       REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CAPATH", 
(long)PDO_MYSQL_ATTR_SSL_CAPATH);
+       REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CIPHER", 
(long)PDO_MYSQL_ATTR_SSL_CIPHER);
        return php_pdo_register_driver(&pdo_mysql_driver);
 }
 /* }}} */

Modified: php/php-src/branches/PHP_5_3/ext/pdo_mysql/php_pdo_mysql_int.h
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pdo_mysql/php_pdo_mysql_int.h      
2011-04-15 14:21:20 UTC (rev 310238)
+++ php/php-src/branches/PHP_5_3/ext/pdo_mysql/php_pdo_mysql_int.h      
2011-04-15 14:24:40 UTC (rev 310239)
@@ -168,7 +168,12 @@
 #endif
        PDO_MYSQL_ATTR_DIRECT_QUERY,
        PDO_MYSQL_ATTR_FOUND_ROWS,
-       PDO_MYSQL_ATTR_IGNORE_SPACE
+       PDO_MYSQL_ATTR_IGNORE_SPACE,
+       PDO_MYSQL_ATTR_SSL_KEY,
+       PDO_MYSQL_ATTR_SSL_CERT,
+       PDO_MYSQL_ATTR_SSL_CA,
+       PDO_MYSQL_ATTR_SSL_CAPATH,
+       PDO_MYSQL_ATTR_SSL_CIPHER
 };

 #endif

Modified: php/php-src/trunk/ext/pdo_mysql/mysql_driver.c
===================================================================
--- php/php-src/trunk/ext/pdo_mysql/mysql_driver.c      2011-04-15 14:21:20 UTC 
(rev 310238)
+++ php/php-src/trunk/ext/pdo_mysql/mysql_driver.c      2011-04-15 14:24:40 UTC 
(rev 310239)
@@ -597,6 +597,7 @@
                char *default_file = NULL, *default_group = NULL;
                long compress = 0;
 #endif
+               char *ssl_key = NULL, *ssl_cert = NULL, *ssl_ca = NULL, 
*ssl_capath = NULL, *ssl_cipher = NULL;
                H->buffered = pdo_attr_lval(driver_options, 
PDO_MYSQL_ATTR_USE_BUFFERED_QUERY, 1 TSRMLS_CC);

                H->emulate_prepare = pdo_attr_lval(driver_options,
@@ -681,6 +682,30 @@
                        }
                }
 #endif
+               ssl_key = pdo_attr_strval(driver_options, 
PDO_MYSQL_ATTR_SSL_KEY, NULL TSRMLS_CC);
+               ssl_cert = pdo_attr_strval(driver_options, 
PDO_MYSQL_ATTR_SSL_CERT, NULL TSRMLS_CC);
+               ssl_ca = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_SSL_CA, 
NULL TSRMLS_CC);
+               ssl_capath = pdo_attr_strval(driver_options, 
PDO_MYSQL_ATTR_SSL_CAPATH, NULL TSRMLS_CC);
+               ssl_cipher = pdo_attr_strval(driver_options, 
PDO_MYSQL_ATTR_SSL_CIPHER, NULL TSRMLS_CC);
+
+               if (ssl_key || ssl_cert || ssl_ca || ssl_capath || ssl_cipher) {
+                       mysql_ssl_set(H->server, ssl_key, ssl_cert, ssl_ca, 
ssl_capath, ssl_cipher);
+                       if (ssl_key) {
+                               efree(ssl_key);
+                       }
+                       if (ssl_cert) {
+                               efree(ssl_cert);
+                       }
+                       if (ssl_ca) {
+                               efree(ssl_ca);
+                       }
+                       if (ssl_capath) {
+                               efree(ssl_capath);
+                       }
+                       if (ssl_cipher) {
+                               efree(ssl_cipher);
+                       }
+               }
        }

 #ifdef PDO_MYSQL_HAS_CHARSET

Modified: php/php-src/trunk/ext/pdo_mysql/pdo_mysql.c
===================================================================
--- php/php-src/trunk/ext/pdo_mysql/pdo_mysql.c 2011-04-15 14:21:20 UTC (rev 
310238)
+++ php/php-src/trunk/ext/pdo_mysql/pdo_mysql.c 2011-04-15 14:24:40 UTC (rev 
310239)
@@ -79,7 +79,11 @@
        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_DIRECT_QUERY", 
(long)PDO_MYSQL_ATTR_DIRECT_QUERY);
        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_FOUND_ROWS", 
(long)PDO_MYSQL_ATTR_FOUND_ROWS);
        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_IGNORE_SPACE", 
(long)PDO_MYSQL_ATTR_IGNORE_SPACE);
-
+       REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_KEY", 
(long)PDO_MYSQL_ATTR_SSL_KEY);
+       REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CERT", 
(long)PDO_MYSQL_ATTR_SSL_CERT);
+       REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CA", 
(long)PDO_MYSQL_ATTR_SSL_CA);
+       REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CAPATH", 
(long)PDO_MYSQL_ATTR_SSL_CAPATH);
+       REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CIPHER", 
(long)PDO_MYSQL_ATTR_SSL_CIPHER);
        return php_pdo_register_driver(&pdo_mysql_driver);
 }
 /* }}} */

Modified: php/php-src/trunk/ext/pdo_mysql/php_pdo_mysql_int.h
===================================================================
--- php/php-src/trunk/ext/pdo_mysql/php_pdo_mysql_int.h 2011-04-15 14:21:20 UTC 
(rev 310238)
+++ php/php-src/trunk/ext/pdo_mysql/php_pdo_mysql_int.h 2011-04-15 14:24:40 UTC 
(rev 310239)
@@ -166,7 +166,12 @@
 #endif
        PDO_MYSQL_ATTR_DIRECT_QUERY,
        PDO_MYSQL_ATTR_FOUND_ROWS,
-       PDO_MYSQL_ATTR_IGNORE_SPACE
+       PDO_MYSQL_ATTR_IGNORE_SPACE,
+       PDO_MYSQL_ATTR_SSL_KEY,
+       PDO_MYSQL_ATTR_SSL_CERT,
+       PDO_MYSQL_ATTR_SSL_CA,
+       PDO_MYSQL_ATTR_SSL_CAPATH,
+       PDO_MYSQL_ATTR_SSL_CIPHER
 };

 #endif

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to