Skip to content

Commit

Permalink
add wechaty ca, see #16
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangchunsheng committed Nov 24, 2021
1 parent e55a52c commit 03c925e
Showing 1 changed file with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use IO\Github\Wechaty\PuppetService\Exceptions\PuppetServiceException;
use IO\Github\Wechaty\Util\Console;
use IO\Github\Wechaty\Util\Logger;
use LM\Exception;
use Wechaty\Puppet\ContactPayloadResponse;
use Wechaty\Puppet\EventResponse;
use Wechaty\Puppet\EventType;
Expand Down Expand Up @@ -797,18 +798,23 @@ function ($metadata,
// WECHATY_PUPPET_SERVICE_TLS_CA_CERT
// WECHATY_PUPPET_SERVICE_TLS_SERVER_NAME
$noTls = getenv("WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_CLIENT");
if($noTls === "true" || $noTls === true) {
Logger::DEBUG("start client with no tls");
$this->_grpcClient = new \Wechaty\PuppetClient($hostname, [
'credentials' => \Grpc\ChannelCredentials::createInsecure(),
'update_metadata' => $updateMetadata,
]);
} else {
Logger::DEBUG("start client with tls");
$this->_grpcClient = new \Wechaty\PuppetClient($hostname, [
'credentials' => \Grpc\ChannelCredentials::createSsl(WechatyCA::TLS_CA_CERT),
'update_metadata' => $updateMetadata,
]);
try {
if($noTls === "true" || $noTls === true) {
Logger::DEBUG("start client with no tls");
$this->_grpcClient = new \Wechaty\PuppetClient($hostname, [
'credentials' => \Grpc\ChannelCredentials::createInsecure(),
'update_metadata' => $updateMetadata,
]);
} else {
Logger::DEBUG("start client with tls");
$this->_grpcClient = new \Wechaty\PuppetClient($hostname, [
'credentials' => \Grpc\ChannelCredentials::createSsl(WechatyCA::TLS_CA_CERT),
'update_metadata' => $updateMetadata,
]);
}
} catch (\Exception $e) {
Logger::ERR("start client error");
Logger::ERR($e);
}

return $this->_grpcClient;
Expand Down

0 comments on commit 03c925e

Please sign in to comment.