diff --git a/src/TencentCloud/Common/Http/HttpConnection.php b/src/TencentCloud/Common/Http/HttpConnection.php index 723b28af86..20090cffbb 100644 --- a/src/TencentCloud/Common/Http/HttpConnection.php +++ b/src/TencentCloud/Common/Http/HttpConnection.php @@ -39,6 +39,7 @@ private function getOptions() $options = ["allow_redirects" => false]; $options["timeout"] = $this->profile->getHttpProfile()->getReqTimeout(); $options["proxy"] = $this->profile->getHttpProfile()->getProxy(); + $options["verify"] = $this->profile->getHttpProfile()->getVerify(); return $options; } diff --git a/src/TencentCloud/Common/Profile/HttpProfile.php b/src/TencentCloud/Common/Profile/HttpProfile.php index 1ee5c6e069..caad7a4d88 100644 --- a/src/TencentCloud/Common/Profile/HttpProfile.php +++ b/src/TencentCloud/Common/Profile/HttpProfile.php @@ -18,6 +18,8 @@ namespace TencentCloud\Common\Profile; +use GuzzleHttp\RequestOptions; + /** * http相关参数类 * Class HttpProfile @@ -76,6 +78,11 @@ class HttpProfile */ private $proxy; + /** + * @var string|bool 请求时验证SSL证书行为 + */ + private $verify; + /** * @var string */ @@ -88,8 +95,8 @@ class HttpProfile /** * HttpProfile constructor. - * @param string $protocol 请求协议 - * @param string $endpoint 请求接入点域名(xx.[region.]tencentcloudapi.com) + * @param string $protocol 请求协议 + * @param string $endpoint 请求接入点域名(xx.[region.]tencentcloudapi.com) * @param string $reqMethod http请求方法,目前支持POST GET * @param integer $reqTimeout 请求超时时间,单位:s */ @@ -99,6 +106,7 @@ public function __construct($protocol = null, $endpoint = null, $reqMethod = nul $this->endpoint = $endpoint; $this->reqTimeout = $reqTimeout ? $reqTimeout : HttpProfile::$TM_MINUTE; $this->protocol = $protocol ? $protocol : HttpProfile::$REQ_HTTPS; + $this->verify = RequestOptions::VERIFY; $this->rootDomain = "tencentcloudapi.com"; $this->keepAlive = false; } @@ -147,6 +155,17 @@ public function setProxy($proxy) $this->proxy = $proxy; } + /** + * 设置成 true 启用SSL证书验证,默认使用操作系统提供的CA包。 + * 设置成 false 禁用证书验证(这是不安全的!)。 + * 设置成字符串启用验证,并使用该字符串作为自定义证书CA包的路径 + * @param string|bool $verify 请求时验证SSL证书行为 + */ + public function setVerify($verify) + { + $this->verify = $verify; + } + /** * 获取请求方法 * @return null|string 请求方法 @@ -192,6 +211,15 @@ public function getProxy() return $this->proxy; } + /** + * 请求时验证SSL证书行为 + * @return bool|string + */ + public function getVerify() + { + return $this->verify; + } + public function setRootDomain($domain) { $this->rootDomain = $domain;