@@ -1870,7 +1870,7 @@ static bool php_phongo_apply_wc_options_to_uri(mongoc_uri_t *uri, bson_t *option
1870
1870
return true;
1871
1871
} /* }}} */
1872
1872
1873
- static mongoc_client_t * php_phongo_make_mongo_client (const mongoc_uri_t * uri , zval * driverOptions TSRMLS_DC ) /* {{{ */
1873
+ static mongoc_client_t * php_phongo_make_mongo_client (php_phongo_manager_t * manager , const mongoc_uri_t * uri , zval * driverOptions TSRMLS_DC ) /* {{{ */
1874
1874
{
1875
1875
#if PHP_VERSION_ID >= 70000
1876
1876
zval * tmp ;
@@ -1954,21 +1954,23 @@ static mongoc_client_t *php_phongo_make_mongo_client(const mongoc_uri_t *uri, zv
1954
1954
1955
1955
#if PHP_VERSION_ID >= 70000
1956
1956
if ((pem = php_stream_context_get_option (ctx , "ssl" , "local_cert" )) != NULL ) {
1957
+ zend_string * s = zval_get_string (pem );
1957
1958
#else
1958
1959
if (SUCCESS == php_stream_context_get_option (ctx , "ssl" , "local_cert" , & pem )) {
1960
+ convert_to_string_ex (pem );
1959
1961
#endif
1960
- char filename [MAXPATHLEN ];
1962
+ /* mongoc_client_set_ssl_opts() copies mongoc_ssl_opt_t shallowly;
1963
+ * its strings must be kept valid for the life of mongoc_client_t */
1964
+ manager -> pem_file = ecalloc (1 , MAXPATHLEN );
1961
1965
1962
1966
#if PHP_VERSION_ID >= 70000
1963
- zend_string * s = zval_get_string (pem );
1964
- if (VCWD_REALPATH (ZSTR_VAL (s ), filename )) {
1967
+ if (VCWD_REALPATH (ZSTR_VAL (s ), manager -> pem_file )) {
1965
1968
#else
1966
- convert_to_string_ex (pem );
1967
- if (VCWD_REALPATH (Z_STRVAL_PP (pem ), filename )) {
1969
+ if (VCWD_REALPATH (Z_STRVAL_PP (pem ), manager -> pem_file )) {
1968
1970
#endif
1969
- mongoc_ssl_opt_t ssl_options ;
1971
+ mongoc_ssl_opt_t ssl_options = { 0 } ;
1970
1972
1971
- ssl_options .pem_file = filename ;
1973
+ ssl_options .pem_file = manager -> pem_file ;
1972
1974
mongoc_client_set_ssl_opts (client , & ssl_options );
1973
1975
}
1974
1976
#if PHP_VERSION_ID >= 70000
@@ -1999,7 +2001,7 @@ bool phongo_manager_init(php_phongo_manager_t *manager, const char *uri_string,
1999
2001
return false;
2000
2002
}
2001
2003
2002
- manager -> client = php_phongo_make_mongo_client (uri , driverOptions TSRMLS_CC );
2004
+ manager -> client = php_phongo_make_mongo_client (manager , uri , driverOptions TSRMLS_CC );
2003
2005
mongoc_uri_destroy (uri );
2004
2006
2005
2007
if (!manager -> client ) {
0 commit comments