diff --git a/src/php/ext/grpc/credentials.c b/src/php/ext/grpc/credentials.c index 8e3b7ff2124..e413070b453 100644 --- a/src/php/ext/grpc/credentials.c +++ b/src/php/ext/grpc/credentials.c @@ -111,21 +111,21 @@ PHP_METHOD(Credentials, createDefault) { * @return Credentials The new SSL credentials object */ PHP_METHOD(Credentials, createSsl) { - char *pem_root_certs; + 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.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( diff --git a/src/php/tests/interop/interop_client.php b/src/php/tests/interop/interop_client.php index 6670ef3ab9c..3d144429549 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; }