Merge pull request #3945 from stanley-cheung/php_remove_ssl_cert_var

PHP: remove ssl_cert_file env var
pull/3946/head
Michael Lumish 9 years ago
commit df5ac28b40
  1. 10
      src/php/ext/grpc/credentials.c
  2. 7
      src/php/tests/interop/interop_client.php

@ -111,21 +111,21 @@ PHP_METHOD(Credentials, createDefault) {
* @return Credentials The new SSL credentials object * @return Credentials The new SSL credentials object
*/ */
PHP_METHOD(Credentials, createSsl) { PHP_METHOD(Credentials, createSsl) {
char *pem_root_certs; char *pem_root_certs = NULL;
grpc_ssl_pem_key_cert_pair pem_key_cert_pair; 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; pem_key_cert_pair.private_key = pem_key_cert_pair.cert_chain = NULL;
/* "s|s!s! == 1 string, 2 optional nullable strings */ /* "|s!s!s! == 3 optional nullable strings */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!s!", if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!s!",
&pem_root_certs, &root_certs_length, &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, &pem_key_cert_pair.cert_chain,
&cert_chain_length) == FAILURE) { &cert_chain_length) == FAILURE) {
zend_throw_exception(spl_ce_InvalidArgumentException, zend_throw_exception(spl_ce_InvalidArgumentException,
"createSsl expects 1 to 3 strings", 1 TSRMLS_CC); "createSsl expects 3 optional strings", 1 TSRMLS_CC);
return; return;
} }
grpc_credentials *creds = grpc_ssl_credentials_create( grpc_credentials *creds = grpc_ssl_credentials_create(

@ -391,12 +391,11 @@ $opts = [];
if ($use_tls) { if ($use_tls) {
if ($use_test_ca) { 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 { } 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['credentials'] = $ssl_credentials;
$opts['grpc.ssl_target_name_override'] = $host_override; $opts['grpc.ssl_target_name_override'] = $host_override;
} }

Loading…
Cancel
Save