diff --git a/src/php/ext/grpc/call_credentials.c b/src/php/ext/grpc/call_credentials.c new file mode 100644 index 0000000000000000000000000000000000000000..17f167befb09e78e34777f3ce4b1444297f658bf --- /dev/null +++ b/src/php/ext/grpc/call_credentials.c @@ -0,0 +1,138 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "channel_credentials.h" +#include "call_credentials.h" + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <php.h> +#include <php_ini.h> +#include <ext/standard/info.h> +#include <ext/spl/spl_exceptions.h> +#include "php_grpc.h" + +#include <zend_exceptions.h> +#include <zend_hash.h> + +#include <grpc/grpc.h> +#include <grpc/grpc_security.h> + +zend_class_entry *grpc_ce_call_credentials; + +/* Frees and destroys an instance of wrapped_grpc_call_credentials */ +void free_wrapped_grpc_call_credentials(void *object TSRMLS_DC) { + wrapped_grpc_call_credentials *creds = + (wrapped_grpc_call_credentials *)object; + if (creds->wrapped != NULL) { + grpc_call_credentials_release(creds->wrapped); + } + efree(creds); +} + +/* Initializes an instance of wrapped_grpc_call_credentials to be + * associated with an object of a class specified by class_type */ +zend_object_value create_wrapped_grpc_call_credentials( + zend_class_entry *class_type TSRMLS_DC) { + zend_object_value retval; + wrapped_grpc_call_credentials *intern; + + intern = (wrapped_grpc_call_credentials *)emalloc( + sizeof(wrapped_grpc_call_credentials)); + memset(intern, 0, sizeof(wrapped_grpc_call_credentials)); + + zend_object_std_init(&intern->std, class_type TSRMLS_CC); + object_properties_init(&intern->std, class_type); + retval.handle = zend_objects_store_put( + intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, + free_wrapped_grpc_call_credentials, NULL TSRMLS_CC); + retval.handlers = zend_get_std_object_handlers(); + return retval; +} + +zval *grpc_php_wrap_call_credentials(grpc_call_credentials *wrapped) { + zval *credentials_object; + MAKE_STD_ZVAL(credentials_object); + object_init_ex(credentials_object, grpc_ce_call_credentials); + wrapped_grpc_call_credentials *credentials = + (wrapped_grpc_call_credentials *)zend_object_store_get_object( + credentials_object TSRMLS_CC); + credentials->wrapped = wrapped; + return credentials_object; +} + +/** + * Create composite credentials from two existing credentials. + * @param CallCredentials cred1 The first credential + * @param CallCredentials cred2 The second credential + * @return CallCredentials The new composite credentials object + */ +PHP_METHOD(CallCredentials, createComposite) { + zval *cred1_obj; + zval *cred2_obj; + + /* "OO" == 3 Objects */ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "OO", &cred1_obj, + grpc_ce_call_credentials, &cred2_obj, + grpc_ce_call_credentials) == FAILURE) { + zend_throw_exception(spl_ce_InvalidArgumentException, + "createComposite expects 2 CallCredentials", + 1 TSRMLS_CC); + return; + } + wrapped_grpc_call_credentials *cred1 = + (wrapped_grpc_call_credentials *)zend_object_store_get_object( + cred1_obj TSRMLS_CC); + wrapped_grpc_call_credentials *cred2 = + (wrapped_grpc_call_credentials *)zend_object_store_get_object( + cred2_obj TSRMLS_CC); + grpc_call_credentials *creds = + grpc_composite_call_credentials_create(cred1->wrapped, cred2->wrapped, + NULL); + zval *creds_object = grpc_php_wrap_call_credentials(creds); + RETURN_DESTROY_ZVAL(creds_object); +} + +static zend_function_entry call_credentials_methods[] = { + PHP_ME(CallCredentials, createComposite, NULL, + ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + PHP_FE_END}; + +void grpc_init_call_credentials(TSRMLS_D) { + zend_class_entry ce; + INIT_CLASS_ENTRY(ce, "Grpc\\CallCredentials", call_credentials_methods); + ce.create_object = create_wrapped_grpc_call_credentials; + grpc_ce_call_credentials = zend_register_internal_class(&ce TSRMLS_CC); +} diff --git a/src/php/ext/grpc/credentials.h b/src/php/ext/grpc/call_credentials.h similarity index 76% rename from src/php/ext/grpc/credentials.h rename to src/php/ext/grpc/call_credentials.h index 86d7ae5b144c983726a861674bbb7a0414f00e31..8f35ac68bc1b7e10543e712e2e5c8d6faf8f3eb5 100755 --- a/src/php/ext/grpc/credentials.h +++ b/src/php/ext/grpc/call_credentials.h @@ -31,8 +31,8 @@ * */ -#ifndef NET_GRPC_PHP_GRPC_CREDENTIALS_H_ -#define NET_GRPC_PHP_GRPC_CREDENTIALS_H_ +#ifndef NET_GRPC_PHP_GRPC_CALL_CREDENTIALS_H_ +#define NET_GRPC_PHP_GRPC_CALL_CREDENTIALS_H_ #ifdef HAVE_CONFIG_H #include "config.h" @@ -46,18 +46,18 @@ #include "grpc/grpc.h" #include "grpc/grpc_security.h" -/* Class entry for the Credentials PHP class */ -extern zend_class_entry *grpc_ce_credentials; +/* Class entry for the CallCredentials PHP class */ +extern zend_class_entry *grpc_ce_call_credentials; -/* Wrapper struct for grpc_credentials that can be associated with a PHP - * object */ -typedef struct wrapped_grpc_credentials { +/* Wrapper struct for grpc_call_credentials that can be associated + * with a PHP object */ +typedef struct wrapped_grpc_call_credentials { zend_object std; - grpc_credentials *wrapped; -} wrapped_grpc_credentials; + grpc_call_credentials *wrapped; +} wrapped_grpc_call_credentials; -/* Initializes the Credentials PHP class */ -void grpc_init_credentials(TSRMLS_D); +/* Initializes the CallCredentials PHP class */ +void grpc_init_call_credentials(TSRMLS_D); -#endif /* NET_GRPC_PHP_GRPC_CREDENTIALS_H_ */ +#endif /* NET_GRPC_PHP_GRPC_CALL_CREDENTIALS_H_ */ diff --git a/src/php/ext/grpc/channel.c b/src/php/ext/grpc/channel.c index a4313b6bd4c0b563d347cd91fa68816815d6b85e..f8c4f0423f2660012ac155ca2f76f5685a5e7a31 100644 --- a/src/php/ext/grpc/channel.c +++ b/src/php/ext/grpc/channel.c @@ -52,7 +52,7 @@ #include <grpc/grpc_security.h> #include "completion_queue.h" -#include "credentials.h" +#include "channel_credentials.h" #include "server.h" #include "timeval.h" @@ -125,21 +125,22 @@ void php_grpc_read_args_array(zval *args_array, grpc_channel_args *args) { /** * Construct an instance of the Channel class. If the $args array contains a - * "credentials" key mapping to a Credentials object, a secure channel will be - * created with those credentials. + * "credentials" key mapping to a ChannelCredentials object, a secure channel + * will be created with those credentials. * @param string $target The hostname to associate with this channel * @param array $args The arguments to pass to the Channel (optional) */ PHP_METHOD(Channel, __construct) { wrapped_grpc_channel *channel = - (wrapped_grpc_channel *)zend_object_store_get_object(getThis() TSRMLS_CC); + (wrapped_grpc_channel *)zend_object_store_get_object( + getThis() TSRMLS_CC); char *target; int target_length; zval *args_array = NULL; grpc_channel_args args; HashTable *array_hash; zval **creds_obj = NULL; - wrapped_grpc_credentials *creds = NULL; + wrapped_grpc_channel_credentials *creds = NULL; /* "s|a" == 1 string, 1 optional array */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|a", &target, &target_length, &args_array) == FAILURE) { @@ -153,13 +154,14 @@ PHP_METHOD(Channel, __construct) { array_hash = Z_ARRVAL_P(args_array); if (zend_hash_find(array_hash, "credentials", sizeof("credentials"), (void **)&creds_obj) == SUCCESS) { - if (zend_get_class_entry(*creds_obj TSRMLS_CC) != grpc_ce_credentials) { + if (zend_get_class_entry(*creds_obj TSRMLS_CC) != + grpc_ce_channel_credentials) { zend_throw_exception(spl_ce_InvalidArgumentException, - "credentials must be a Credentials object", + "credentials must be a ChannelCredentials object", 1 TSRMLS_CC); return; } - creds = (wrapped_grpc_credentials *)zend_object_store_get_object( + creds = (wrapped_grpc_channel_credentials *)zend_object_store_get_object( *creds_obj TSRMLS_CC); zend_hash_del(array_hash, "credentials", 12); } diff --git a/src/php/ext/grpc/credentials.c b/src/php/ext/grpc/channel_credentials.c similarity index 51% rename from src/php/ext/grpc/credentials.c rename to src/php/ext/grpc/channel_credentials.c index 8e3b7ff21241a51f874c8e24133863fbabf441cf..df4a5d516246829bd02ffdaf6cf49f53039361c3 100644 --- a/src/php/ext/grpc/credentials.c +++ b/src/php/ext/grpc/channel_credentials.c @@ -31,7 +31,8 @@ * */ -#include "credentials.h" +#include "channel_credentials.h" +#include "call_credentials.h" #ifdef HAVE_CONFIG_H #include "config.h" @@ -49,55 +50,56 @@ #include <grpc/grpc.h> #include <grpc/grpc_security.h> -zend_class_entry *grpc_ce_credentials; +zend_class_entry *grpc_ce_channel_credentials; -/* Frees and destroys an instance of wrapped_grpc_credentials */ -void free_wrapped_grpc_credentials(void *object TSRMLS_DC) { - wrapped_grpc_credentials *creds = (wrapped_grpc_credentials *)object; +/* Frees and destroys an instance of wrapped_grpc_channel_credentials */ +void free_wrapped_grpc_channel_credentials(void *object TSRMLS_DC) { + wrapped_grpc_channel_credentials *creds = + (wrapped_grpc_channel_credentials *)object; if (creds->wrapped != NULL) { - grpc_credentials_release(creds->wrapped); + grpc_channel_credentials_release(creds->wrapped); } efree(creds); } -/* Initializes an instance of wrapped_grpc_credentials to be associated with an - * object of a class specified by class_type */ -zend_object_value create_wrapped_grpc_credentials(zend_class_entry *class_type - TSRMLS_DC) { +/* Initializes an instance of wrapped_grpc_channel_credentials to be + * associated with an object of a class specified by class_type */ +zend_object_value create_wrapped_grpc_channel_credentials( + zend_class_entry *class_type TSRMLS_DC) { zend_object_value retval; - wrapped_grpc_credentials *intern; + wrapped_grpc_channel_credentials *intern; - intern = - (wrapped_grpc_credentials *)emalloc(sizeof(wrapped_grpc_credentials)); - memset(intern, 0, sizeof(wrapped_grpc_credentials)); + intern = (wrapped_grpc_channel_credentials *)emalloc( + sizeof(wrapped_grpc_channel_credentials)); + memset(intern, 0, sizeof(wrapped_grpc_channel_credentials)); zend_object_std_init(&intern->std, class_type TSRMLS_CC); object_properties_init(&intern->std, class_type); retval.handle = zend_objects_store_put( intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, - free_wrapped_grpc_credentials, NULL TSRMLS_CC); + free_wrapped_grpc_channel_credentials, NULL TSRMLS_CC); retval.handlers = zend_get_std_object_handlers(); return retval; } -zval *grpc_php_wrap_credentials(grpc_credentials *wrapped) { +zval *grpc_php_wrap_channel_credentials(grpc_channel_credentials *wrapped) { zval *credentials_object; MAKE_STD_ZVAL(credentials_object); - object_init_ex(credentials_object, grpc_ce_credentials); - wrapped_grpc_credentials *credentials = - (wrapped_grpc_credentials *)zend_object_store_get_object( + object_init_ex(credentials_object, grpc_ce_channel_credentials); + wrapped_grpc_channel_credentials *credentials = + (wrapped_grpc_channel_credentials *)zend_object_store_get_object( credentials_object TSRMLS_CC); credentials->wrapped = wrapped; return credentials_object; } /** - * Create a default credentials object. - * @return Credentials The new default credentials object + * Create a default channel credentials object. + * @return ChannelCredentials The new default channel credentials object */ -PHP_METHOD(Credentials, createDefault) { - grpc_credentials *creds = grpc_google_default_credentials_create(); - zval *creds_object = grpc_php_wrap_credentials(creds); +PHP_METHOD(ChannelCredentials, createDefault) { + grpc_channel_credentials *creds = grpc_google_default_credentials_create(); + zval *creds_object = grpc_php_wrap_channel_credentials(creds); RETURN_DESTROY_ZVAL(creds_object); } @@ -108,84 +110,78 @@ PHP_METHOD(Credentials, createDefault) { * (optional) * @param string pem_cert_chain PEM encoding of the client's certificate chain * (optional) - * @return Credentials The new SSL credentials object + * @return ChannelCredentials The new SSL credentials object */ -PHP_METHOD(Credentials, createSsl) { - char *pem_root_certs; +PHP_METHOD(ChannelCredentials, createSsl) { + char *pem_root_certs = NULL; grpc_ssl_pem_key_cert_pair pem_key_cert_pair; - int root_certs_length, private_key_length = 0, cert_chain_length = 0; + int root_certs_length = 0, private_key_length = 0, cert_chain_length = 0; pem_key_cert_pair.private_key = pem_key_cert_pair.cert_chain = NULL; - /* "s|s!s! == 1 string, 2 optional nullable strings */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!s!", + /* "|s!s!s! == 3 optional nullable strings */ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!s!", &pem_root_certs, &root_certs_length, - &pem_key_cert_pair.private_key, &private_key_length, + &pem_key_cert_pair.private_key, + &private_key_length, &pem_key_cert_pair.cert_chain, &cert_chain_length) == FAILURE) { zend_throw_exception(spl_ce_InvalidArgumentException, - "createSsl expects 1 to 3 strings", 1 TSRMLS_CC); + "createSsl expects 3 optional strings", 1 TSRMLS_CC); return; } - grpc_credentials *creds = grpc_ssl_credentials_create( + grpc_channel_credentials *creds = grpc_ssl_credentials_create( pem_root_certs, pem_key_cert_pair.private_key == NULL ? NULL : &pem_key_cert_pair, NULL); - zval *creds_object = grpc_php_wrap_credentials(creds); + zval *creds_object = grpc_php_wrap_channel_credentials(creds); RETURN_DESTROY_ZVAL(creds_object); } /** * Create composite credentials from two existing credentials. - * @param Credentials cred1 The first credential - * @param Credentials cred2 The second credential - * @return Credentials The new composite credentials object + * @param ChannelCredentials cred1 The first credential + * @param CallCredentials cred2 The second credential + * @return ChannelCredentials The new composite credentials object */ -PHP_METHOD(Credentials, createComposite) { +PHP_METHOD(ChannelCredentials, createComposite) { zval *cred1_obj; zval *cred2_obj; /* "OO" == 3 Objects */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "OO", &cred1_obj, - grpc_ce_credentials, &cred2_obj, - grpc_ce_credentials) == FAILURE) { + grpc_ce_channel_credentials, &cred2_obj, + grpc_ce_call_credentials) == FAILURE) { zend_throw_exception(spl_ce_InvalidArgumentException, "createComposite expects 2 Credentials", 1 TSRMLS_CC); return; } - wrapped_grpc_credentials *cred1 = - (wrapped_grpc_credentials *)zend_object_store_get_object( + wrapped_grpc_channel_credentials *cred1 = + (wrapped_grpc_channel_credentials *)zend_object_store_get_object( cred1_obj TSRMLS_CC); - wrapped_grpc_credentials *cred2 = - (wrapped_grpc_credentials *)zend_object_store_get_object( + wrapped_grpc_call_credentials *cred2 = + (wrapped_grpc_call_credentials *)zend_object_store_get_object( cred2_obj TSRMLS_CC); - grpc_credentials *creds = - grpc_composite_credentials_create(cred1->wrapped, cred2->wrapped, NULL); - zval *creds_object = grpc_php_wrap_credentials(creds); + grpc_channel_credentials *creds = + grpc_composite_channel_credentials_create(cred1->wrapped, cred2->wrapped, + NULL); + zval *creds_object = grpc_php_wrap_channel_credentials(creds); RETURN_DESTROY_ZVAL(creds_object); } -/** - * Create Google Compute Engine credentials - * @return Credentials The new GCE credentials object - */ -PHP_METHOD(Credentials, createGce) { - grpc_credentials *creds = grpc_google_compute_engine_credentials_create(NULL); - zval *creds_object = grpc_php_wrap_credentials(creds); - RETURN_DESTROY_ZVAL(creds_object); -} - -static zend_function_entry credentials_methods[] = { - PHP_ME(Credentials, createDefault, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) - PHP_ME(Credentials, createSsl, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) - PHP_ME(Credentials, createComposite, NULL, - ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) - PHP_ME(Credentials, createGce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) - PHP_FE_END}; +static zend_function_entry channel_credentials_methods[] = { + PHP_ME(ChannelCredentials, createDefault, NULL, + ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + PHP_ME(ChannelCredentials, createSsl, NULL, + ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + PHP_ME(ChannelCredentials, createComposite, NULL, + ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + PHP_FE_END}; -void grpc_init_credentials(TSRMLS_D) { +void grpc_init_channel_credentials(TSRMLS_D) { zend_class_entry ce; - INIT_CLASS_ENTRY(ce, "Grpc\\Credentials", credentials_methods); - ce.create_object = create_wrapped_grpc_credentials; - grpc_ce_credentials = zend_register_internal_class(&ce TSRMLS_CC); + INIT_CLASS_ENTRY(ce, "Grpc\\ChannelCredentials", + channel_credentials_methods); + ce.create_object = create_wrapped_grpc_channel_credentials; + grpc_ce_channel_credentials = zend_register_internal_class(&ce TSRMLS_CC); } diff --git a/src/php/ext/grpc/channel_credentials.h b/src/php/ext/grpc/channel_credentials.h new file mode 100755 index 0000000000000000000000000000000000000000..d89984ce604076ee41a8a2b97e05391857e15060 --- /dev/null +++ b/src/php/ext/grpc/channel_credentials.h @@ -0,0 +1,63 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef NET_GRPC_PHP_GRPC_CHANNEL_CREDENTIALS_H_ +#define NET_GRPC_PHP_GRPC_CHANNEL_CREDENTIALS_H_ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" +#include "php_ini.h" +#include "ext/standard/info.h" +#include "php_grpc.h" + +#include "grpc/grpc.h" +#include "grpc/grpc_security.h" + +/* Class entry for the ChannelCredentials PHP class */ +extern zend_class_entry *grpc_ce_channel_credentials; + +/* Wrapper struct for grpc_channel_credentials that can be associated + * with a PHP object */ +typedef struct wrapped_grpc_channel_credentials { + zend_object std; + + grpc_channel_credentials *wrapped; +} wrapped_grpc_channel_credentials; + +/* Initializes the ChannelCredentials PHP class */ +void grpc_init_channel_credentials(TSRMLS_D); + +#endif /* NET_GRPC_PHP_GRPC_CHANNEL_CREDENTIALS_H_ */ diff --git a/src/php/ext/grpc/config.m4 b/src/php/ext/grpc/config.m4 index 8bacdfbfecac1ea6537d266896ad85947ec4ec09..792868794315323c1b454ceb87b1ad80c93eb81c 100755 --- a/src/php/ext/grpc/config.m4 +++ b/src/php/ext/grpc/config.m4 @@ -71,5 +71,7 @@ if test "$PHP_GRPC" != "no"; then PHP_SUBST(GRPC_SHARED_LIBADD) - PHP_NEW_EXTENSION(grpc, byte_buffer.c call.c channel.c completion_queue.c credentials.c timeval.c server.c server_credentials.c php_grpc.c, $ext_shared, , -Wall -Werror -std=c11) + PHP_NEW_EXTENSION(grpc, byte_buffer.c call.c call_credentials.c channel.c \ + channel_credentials.c completion_queue.c timeval.c server.c \ + server_credentials.c php_grpc.c, $ext_shared, , -Wall -Werror -std=c11) fi diff --git a/src/php/ext/grpc/package.xml b/src/php/ext/grpc/package.xml index 921cfc6ae68d085120331c0de9db36ff4f2f7d69..a2e3e2826a77441e92947c42f0f2ec0c39063f0c 100644 --- a/src/php/ext/grpc/package.xml +++ b/src/php/ext/grpc/package.xml @@ -10,8 +10,8 @@ <email>grpc-packages@google.com</email> <active>yes</active> </lead> - <date>2015-10-07</date> - <time>13:40:54</time> + <date>2015-10-21</date> + <time>17:04:32</time> <version> <release>0.6.1</release> <api>0.6.0</api> @@ -30,16 +30,18 @@ <file baseinstalldir="/" md5sum="c8de0f819499c48adfc8d7f472c0196b" name="byte_buffer.h" role="src" /> <file baseinstalldir="/" md5sum="d64c9005993de02abac55664b0b9e0b2" name="call.c" role="src" /> <file baseinstalldir="/" md5sum="26acbf04c30162c2d2aca4688bb2aec8" name="call.h" role="src" /> - <file baseinstalldir="/" md5sum="15e56239b32c803f073e8a2b9f96e8c3" name="channel.c" role="src" /> + <file baseinstalldir="/" md5sum="6fa13d260dfde216f795225644f04e7a" name="call_credentials.c" role="src" /> + <file baseinstalldir="/" md5sum="e45269975f9a30fd349a90daf6b31aa2" name="call_credentials.h" role="src" /> + <file baseinstalldir="/" md5sum="0779db3b196c98081b2260ceec22cd4d" name="channel.c" role="src" /> <file baseinstalldir="/" md5sum="ed4b00c0cf3702b115d0cfa87450dc09" name="channel.h" role="src" /> + <file baseinstalldir="/" md5sum="1b40f50fa6184ad7d24a961ac76151ff" name="channel_credentials.c" role="src" /> + <file baseinstalldir="/" md5sum="a86250e03f610ce6c2c7595a84e08821" name="channel_credentials.h" role="src" /> <file baseinstalldir="/" md5sum="55ab7a42f9dd9bfc7e28a61cfc5fca63" name="completion_queue.c" role="src" /> <file baseinstalldir="/" md5sum="f10b5bb232d74a6878e829e2e76cdaa2" name="completion_queue.h" role="src" /> - <file baseinstalldir="/" md5sum="a22f8eac0164761058cc4d9eb2ceb069" name="config.m4" role="src" /> - <file baseinstalldir="/" md5sum="588752c908f7bc1663f7b8fc922ae661" name="credentials.c" role="src" /> - <file baseinstalldir="/" md5sum="6988d6e97c19c8f8e3eb92371cf8246b" name="credentials.h" role="src" /> + <file baseinstalldir="/" md5sum="c7bba7f0f00d1b1483de457d55311382" name="config.m4" role="src" /> <file baseinstalldir="/" md5sum="38a1bc979d810c36ebc2a52d4b7b5319" name="CREDITS" role="doc" /> <file baseinstalldir="/" md5sum="3f35b472bbdef5a788cd90617d7d0847" name="LICENSE" role="doc" /> - <file baseinstalldir="/" md5sum="b77f1f3941aaf7a21090b493e9f26037" name="php_grpc.c" role="src" /> + <file baseinstalldir="/" md5sum="3131a8af38fe5918e5409016b89d6cdb" name="php_grpc.c" role="src" /> <file baseinstalldir="/" md5sum="673b07859d9f69232f8a754c56780686" name="php_grpc.h" role="src" /> <file baseinstalldir="/" md5sum="7533a6d3ea02c78cad23a9651de0825d" name="README.md" role="doc" /> <file baseinstalldir="/" md5sum="3e4e960454ebb2fc7b78a840493f5315" name="server.c" role="src" /> @@ -122,7 +124,7 @@ Update to wrap gRPC C Core version 0.10.0 <release>beta</release> <api>beta</api> </stability> - <date>2015-10-07</date> + <date>2015-10-21</date> <license>BSD</license> <notes> - fixed undefined constant fatal error when run with apache/nginx #2275 diff --git a/src/php/ext/grpc/php_grpc.c b/src/php/ext/grpc/php_grpc.c index fcd94a6306230db39d60f2ede6305c950978931c..762c01385c95fae2a894986f953b8c9d07f59526 100644 --- a/src/php/ext/grpc/php_grpc.c +++ b/src/php/ext/grpc/php_grpc.c @@ -35,7 +35,8 @@ #include "channel.h" #include "server.h" #include "timeval.h" -#include "credentials.h" +#include "channel_credentials.h" +#include "call_credentials.h" #include "server_credentials.h" #include "completion_queue.h" @@ -233,7 +234,8 @@ PHP_MINIT_FUNCTION(grpc) { grpc_init_channel(TSRMLS_C); grpc_init_server(TSRMLS_C); grpc_init_timeval(TSRMLS_C); - grpc_init_credentials(TSRMLS_C); + grpc_init_channel_credentials(TSRMLS_C); + grpc_init_call_credentials(TSRMLS_C); grpc_init_server_credentials(TSRMLS_C); grpc_php_init_completion_queue(TSRMLS_C); return SUCCESS; diff --git a/src/php/tests/interop/interop_client.php b/src/php/tests/interop/interop_client.php index 6670ef3ab9c29cf3a0db06ed5fd1e55b356fc735..3d1444295497fe881f932e3f4d2d747198bf99c5 100755 --- a/src/php/tests/interop/interop_client.php +++ b/src/php/tests/interop/interop_client.php @@ -392,12 +392,11 @@ $opts = []; if ($use_tls) { if ($use_test_ca) { - $ssl_cert_file = dirname(__FILE__) . '/../data/ca.pem'; + $ssl_credentials = Grpc\Credentials::createSsl( + file_get_contents(dirname(__FILE__) . '/../data/ca.pem')); } else { - $ssl_cert_file = getenv('SSL_CERT_FILE'); + $ssl_credentials = Grpc\Credentials::createSsl(); } - $ssl_credentials = Grpc\Credentials::createSsl( - file_get_contents($ssl_cert_file)); $opts['credentials'] = $ssl_credentials; $opts['grpc.ssl_target_name_override'] = $host_override; } diff --git a/src/php/tests/unit_tests/SecureEndToEndTest.php b/src/php/tests/unit_tests/SecureEndToEndTest.php index d7fca14a0d5dbccace4ad9d4abcec36b7b556982..75256e5d33c2a8a3eb5a2fb7b05f15d65063f42c 100755 --- a/src/php/tests/unit_tests/SecureEndToEndTest.php +++ b/src/php/tests/unit_tests/SecureEndToEndTest.php @@ -33,7 +33,7 @@ */ class SecureEndToEndTest extends PHPUnit_Framework_TestCase{ public function setUp() { - $credentials = Grpc\Credentials::createSsl( + $channel_credentials = Grpc\ChannelCredentials::createSsl( file_get_contents(dirname(__FILE__) . '/../data/ca.pem')); $server_credentials = Grpc\ServerCredentials::createSsl( null, @@ -49,7 +49,7 @@ class SecureEndToEndTest extends PHPUnit_Framework_TestCase{ [ 'grpc.ssl_target_name_override' => $this->host_override, 'grpc.default_authority' => $this->host_override, - 'credentials' => $credentials + 'credentials' => $channel_credentials ]); }