@@ -197,6 +197,11 @@ class Client
197197 */
198198 protected $ savedRequests ;
199199
200+ /**
201+ * @var bool
202+ */
203+ protected $ verifySSLCerts ;
204+
200205 /**
201206 * @var bool
202207 */
@@ -212,27 +217,30 @@ class Client
212217 /**
213218 * Initialize the client.
214219 *
215- * @param string $host the base url (e.g. https://api.sendgrid.com)
216- * @param array $headers global request headers
217- * @param string $version api version (configurable) - this is specific to the SendGrid API
218- * @param array $path holds the segments of the url path
219- * @param array $curlOptions extra options to set during curl initialization
220- * @param bool $retryOnLimit set default retry on limit flag
220+ * @param string $host the base url (e.g. https://api.sendgrid.com)
221+ * @param array $headers global request headers
222+ * @param string $version api version (configurable) - this is specific to the SendGrid API
223+ * @param array $path holds the segments of the url path
224+ * @param array $curlOptions extra options to set during curl initialization
225+ * @param bool $retryOnLimit set default retry on limit flag
226+ * @param bool $verifySSLCerts set default verify certificates flag
221227 */
222228 public function __construct (
223229 $ host ,
224230 $ headers = null ,
225231 $ version = null ,
226232 $ path = null ,
227233 $ curlOptions = null ,
228- $ retryOnLimit = false
234+ $ retryOnLimit = false ,
235+ $ verifySSLCerts = true
229236 ) {
230237 $ this ->host = $ host ;
231238 $ this ->headers = $ headers ?: [];
232239 $ this ->version = $ version ;
233240 $ this ->path = $ path ?: [];
234241 $ this ->curlOptions = $ curlOptions ?: [];
235242 $ this ->retryOnLimit = $ retryOnLimit ;
243+ $ this ->verifySSLCerts = $ verifySSLCerts ;
236244 $ this ->isConcurrentRequest = false ;
237245 $ this ->savedRequests = [];
238246 }
@@ -306,7 +314,21 @@ public function setRetryOnLimit($retry)
306314 }
307315
308316 /**
309- * Set concurrent request flag.
317+ * Set default verify certificates flag
318+ *
319+ * @param bool $verifySSLCerts
320+ *
321+ * @return Client
322+ */
323+ public function setVerifySSLCerts ($ verifySSLCerts )
324+ {
325+ $ this ->verifySSLCerts = $ verifySSLCerts ;
326+
327+ return $ this ;
328+ }
329+
330+ /**
331+ * Set concurrent request flag
310332 *
311333 * @param bool $isConcurrent
312334 *
@@ -352,7 +374,7 @@ private function createCurlOptions($method, $body = null, $headers = null)
352374 CURLOPT_RETURNTRANSFER => true ,
353375 CURLOPT_HEADER => true ,
354376 CURLOPT_CUSTOMREQUEST => strtoupper ($ method ),
355- CURLOPT_SSL_VERIFYPEER => true ,
377+ CURLOPT_SSL_VERIFYPEER => $ this -> verifySSLCerts ,
356378 CURLOPT_FAILONERROR => false ,
357379 ] + $ this ->curlOptions ;
358380
@@ -572,6 +594,7 @@ public function _($name = null)
572594 }
573595 $ client = new static ($ this ->host , $ this ->headers , $ this ->version , $ this ->path );
574596 $ client ->setCurlOptions ($ this ->curlOptions );
597+ $ client ->setVerifySSLCerts ($ this ->verifySSLCerts );
575598 $ client ->setRetryOnLimit ($ this ->retryOnLimit );
576599 $ this ->path = [];
577600
0 commit comments