From cde12a523ac6dd2fc3fadab37834ef1a19f074e3 Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Thu, 1 Sep 2016 22:03:20 -0700 Subject: php: use ssl hostname_override as auth audience uri if present --- src/php/lib/Grpc/BaseStub.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/php/lib/Grpc') diff --git a/src/php/lib/Grpc/BaseStub.php b/src/php/lib/Grpc/BaseStub.php index 2fec1bd9cc..d850eebc78 100644 --- a/src/php/lib/Grpc/BaseStub.php +++ b/src/php/lib/Grpc/BaseStub.php @@ -41,6 +41,7 @@ namespace Grpc; class BaseStub { private $hostname; + private $hostname_override; private $channel; // a callback function @@ -75,6 +76,9 @@ class BaseStub } else { $opts['grpc.primary_user_agent'] = ''; } + if (!empty($opts['grpc.ssl_target_name_override'])) { + $this->hostname_override = $opts['grpc.ssl_target_name_override']; + } $opts['grpc.primary_user_agent'] .= 'grpc-php/'.$package_config['version']; if (!array_key_exists('credentials', $opts)) { @@ -173,7 +177,12 @@ class BaseStub } $service_name = substr($method, 0, $last_slash_idx); - return 'https://'.$this->hostname.$service_name; + if ($this->hostname_override) { + $hostname = $this->hostname_override; + } else { + $hostname = $this->hostname; + } + return 'https://'.$hostname.$service_name; } /** -- cgit v1.2.3