@@ -1864,7 +1864,7 @@ static bool php_phongo_apply_wc_options_to_client(mongoc_client_t *client, bson_
1864
1864
return true;
1865
1865
} /* }}} */
1866
1866
1867
- static mongoc_client_t * php_phongo_make_mongo_client (const mongoc_uri_t * uri , zval * driverOptions TSRMLS_DC ) /* {{{ */
1867
+ static mongoc_client_t * php_phongo_make_mongo_client (php_phongo_manager_t * manager , const mongoc_uri_t * uri , zval * driverOptions TSRMLS_DC ) /* {{{ */
1868
1868
{
1869
1869
#if PHP_VERSION_ID >= 70000
1870
1870
zval * tmp ;
@@ -1948,21 +1948,23 @@ static mongoc_client_t *php_phongo_make_mongo_client(const mongoc_uri_t *uri, zv
1948
1948
1949
1949
#if PHP_VERSION_ID >= 70000
1950
1950
if ((pem = php_stream_context_get_option (ctx , "ssl" , "local_cert" )) != NULL ) {
1951
+ zend_string * s = zval_get_string (pem );
1951
1952
#else
1952
1953
if (SUCCESS == php_stream_context_get_option (ctx , "ssl" , "local_cert" , & pem )) {
1954
+ convert_to_string_ex (pem );
1953
1955
#endif
1954
- char filename [MAXPATHLEN ];
1956
+ /* mongoc_client_set_ssl_opts() copies mongoc_ssl_opt_t shallowly;
1957
+ * its strings must be kept valid for the life of mongoc_client_t */
1958
+ manager -> pem_file = ecalloc (1 , MAXPATHLEN );
1955
1959
1956
1960
#if PHP_VERSION_ID >= 70000
1957
- zend_string * s = zval_get_string (pem );
1958
- if (VCWD_REALPATH (ZSTR_VAL (s ), filename )) {
1961
+ if (VCWD_REALPATH (ZSTR_VAL (s ), manager -> pem_file )) {
1959
1962
#else
1960
- convert_to_string_ex (pem );
1961
- if (VCWD_REALPATH (Z_STRVAL_PP (pem ), filename )) {
1963
+ if (VCWD_REALPATH (Z_STRVAL_PP (pem ), manager -> pem_file )) {
1962
1964
#endif
1963
- mongoc_ssl_opt_t ssl_options ;
1965
+ mongoc_ssl_opt_t ssl_options = { 0 } ;
1964
1966
1965
- ssl_options .pem_file = filename ;
1967
+ ssl_options .pem_file = manager -> pem_file ;
1966
1968
mongoc_client_set_ssl_opts (client , & ssl_options );
1967
1969
}
1968
1970
#if PHP_VERSION_ID >= 70000
@@ -1985,7 +1987,7 @@ bool phongo_manager_init(php_phongo_manager_t *manager, const char *uri_string,
1985
1987
return false;
1986
1988
}
1987
1989
1988
- manager -> client = php_phongo_make_mongo_client (uri , driverOptions TSRMLS_CC );
1990
+ manager -> client = php_phongo_make_mongo_client (manager , uri , driverOptions TSRMLS_CC );
1989
1991
mongoc_uri_destroy (uri );
1990
1992
1991
1993
if (!manager -> client ) {
0 commit comments