@@ -197,6 +197,11 @@ class Client
197
197
*/
198
198
protected $ savedRequests ;
199
199
200
+ /**
201
+ * @var bool
202
+ */
203
+ protected $ verifySSLCerts ;
204
+
200
205
/**
201
206
* @var bool
202
207
*/
@@ -212,27 +217,30 @@ class Client
212
217
/**
213
218
* Initialize the client.
214
219
*
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
221
227
*/
222
228
public function __construct (
223
229
$ host ,
224
230
$ headers = null ,
225
231
$ version = null ,
226
232
$ path = null ,
227
233
$ curlOptions = null ,
228
- $ retryOnLimit = false
234
+ $ retryOnLimit = false ,
235
+ $ verifySSLCerts = true
229
236
) {
230
237
$ this ->host = $ host ;
231
238
$ this ->headers = $ headers ?: [];
232
239
$ this ->version = $ version ;
233
240
$ this ->path = $ path ?: [];
234
241
$ this ->curlOptions = $ curlOptions ?: [];
235
242
$ this ->retryOnLimit = $ retryOnLimit ;
243
+ $ this ->verifySSLCerts = $ verifySSLCerts ;
236
244
$ this ->isConcurrentRequest = false ;
237
245
$ this ->savedRequests = [];
238
246
}
@@ -306,7 +314,21 @@ public function setRetryOnLimit($retry)
306
314
}
307
315
308
316
/**
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
310
332
*
311
333
* @param bool $isConcurrent
312
334
*
@@ -352,7 +374,7 @@ private function createCurlOptions($method, $body = null, $headers = null)
352
374
CURLOPT_RETURNTRANSFER => true ,
353
375
CURLOPT_HEADER => true ,
354
376
CURLOPT_CUSTOMREQUEST => strtoupper ($ method ),
355
- CURLOPT_SSL_VERIFYPEER => true ,
377
+ CURLOPT_SSL_VERIFYPEER => $ this -> verifySSLCerts ,
356
378
CURLOPT_FAILONERROR => false ,
357
379
] + $ this ->curlOptions ;
358
380
@@ -572,6 +594,7 @@ public function _($name = null)
572
594
}
573
595
$ client = new static ($ this ->host , $ this ->headers , $ this ->version , $ this ->path );
574
596
$ client ->setCurlOptions ($ this ->curlOptions );
597
+ $ client ->setVerifySSLCerts ($ this ->verifySSLCerts );
575
598
$ client ->setRetryOnLimit ($ this ->retryOnLimit );
576
599
$ this ->path = [];
577
600
0 commit comments