"_local_cert" and "_passphrase" properties moved into "_stream_context".

As a result now it is possible to use certificates during access WSDL files.
This commit is contained in:
Dmitry Stogov 2005-07-20 10:21:49 +00:00
parent 3102638061
commit e07d2f4803
3 changed files with 21 additions and 21 deletions

View File

@ -142,23 +142,10 @@ static php_stream* http_connect(zval* this_ptr, php_url *phpurl, int use_ssl, in
if (SUCCESS == zend_hash_find(Z_OBJPROP_P(this_ptr),
"_stream_context", sizeof("_stream_context"), (void**)&tmp)) {
context = php_stream_context_from_zval(*tmp, 0);
} else {
context = php_stream_context_alloc();
}
namelen = spprintf(&name, 0, "%s://%s:%d", (use_ssl && !*use_proxy)? "ssl" : "tcp", host, port);
if (use_ssl) {
zval **tmp;
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_local_cert", sizeof("_local_cert"), (void **) &tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_STRING) {
php_stream_context_set_option(context, "ssl", "local_cert", *tmp);
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_passphrase", sizeof("_passphrase"), (void **) &tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_STRING) {
php_stream_context_set_option(context, "ssl", "passphrase", *tmp);
}
}
}
stream = php_stream_xport_create(name, namelen,
ENFORCE_SAFE_MODE | REPORT_ERRORS,
STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT,

View File

@ -2214,9 +2214,14 @@ sdlPtr get_sdl(zval *this_ptr, char *uri TSRMLS_DC)
char* old_error_code = SOAP_GLOBAL(error_code);
int uri_len;
php_stream_context *context=NULL;
zval **proxy_host, **proxy_port, *orig_context, *new_context;
zval **tmp, **proxy_host, **proxy_port, *orig_context, *new_context;
smart_str headers = {0};
if (SUCCESS == zend_hash_find(Z_OBJPROP_P(this_ptr),
"_stream_context", sizeof("_stream_context"), (void**)&tmp)) {
context = php_stream_context_from_zval(*tmp, 0);
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_proxy_host", sizeof("_proxy_host"), (void **) &proxy_host) == SUCCESS &&
Z_TYPE_PP(proxy_host) == IS_STRING &&
zend_hash_find(Z_OBJPROP_P(this_ptr), "_proxy_port", sizeof("_proxy_port"), (void **) &proxy_port) == SUCCESS &&
@ -2235,7 +2240,9 @@ sdlPtr get_sdl(zval *this_ptr, char *uri TSRMLS_DC)
ZVAL_STRING(str_proxy, proxy.c, 1);
smart_str_free(&proxy);
context = php_stream_context_alloc();
if (!context) {
context = php_stream_context_alloc();
}
php_stream_context_set_option(context, "http", "proxy", str_proxy);
zval_ptr_dtor(&str_proxy);

View File

@ -2030,6 +2030,7 @@ PHP_METHOD(SoapClient, SoapClient)
zval *wsdl;
zval *options = NULL;
int soap_version = SOAP_1_1;
php_stream_context *context = NULL;
SOAP_CLIENT_BEGIN_CODE();
@ -2074,10 +2075,7 @@ PHP_METHOD(SoapClient, SoapClient)
if (zend_hash_find(ht, "stream_context", sizeof("stream_context"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_RESOURCE) {
php_stream_context *context = php_stream_context_from_zval(*tmp, 1);
if (context) {
add_property_resource(this_ptr, "_stream_context", context->rsrc_id);
}
context = php_stream_context_from_zval(*tmp, 1);
}
if (zend_hash_find(ht, "location", sizeof("location"), (void**)&tmp) == SUCCESS &&
@ -2125,10 +2123,13 @@ PHP_METHOD(SoapClient, SoapClient)
}
if (zend_hash_find(ht, "local_cert", sizeof("local_cert"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_STRING) {
add_property_stringl(this_ptr, "_local_cert", Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
if (!context) {
context = php_stream_context_alloc();
}
php_stream_context_set_option(context, "ssl", "local_cert", *tmp);
if (zend_hash_find(ht, "passphrase", sizeof("passphrase"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_STRING) {
add_property_stringl(this_ptr, "_passphrase", Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
php_stream_context_set_option(context, "ssl", "passphrase", *tmp);
}
}
if (zend_hash_find(ht, "trace", sizeof("trace"), (void**)&tmp) == SUCCESS &&
@ -2181,6 +2182,11 @@ PHP_METHOD(SoapClient, SoapClient)
Z_TYPE_PP(tmp) == IS_LONG && Z_LVAL_PP(tmp) > 0) {
add_property_long(this_ptr, "_connection_timeout", Z_LVAL_PP(tmp));
}
if (context) {
add_property_resource(this_ptr, "_stream_context", context->rsrc_id);
}
} else if (wsdl == NULL) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "'location' and 'uri' options are requred in nonWSDL mode");
return;