Skip to content

Commit 80f0285

Browse files
committed
Auto-locate the system's CA bundle or fall back to Mozilla's (#90)
1 parent 0204332 commit 80f0285

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

composer.json

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
"phpunit/phpunit": "~4.4",
2424
"squizlabs/php_codesniffer": "~2.0"
2525
},
26+
"suggest": {
27+
"composer/ca-bundle": "Including this library will ensure that a valid CA bundle is available for secure connections"
28+
},
2629
"autoload": {
2730
"psr-4": {
2831
"SendGrid\\": "lib/"

lib/Client.php

+9
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,15 @@ private function createCurlOptions($method, $body = null, $headers = null)
367367
}
368368
$options[CURLOPT_HTTPHEADER] = $headers;
369369

370+
if (class_exists('\\Composer\\CaBundle\\CaBundle') && method_exists('\\Composer\\CaBundle\\CaBundle', 'getSystemCaRootBundlePath')) {
371+
$caPathOrFile = \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath();
372+
if (is_dir($caPathOrFile) || (is_link($caPathOrFile) && is_dir(readlink($caPathOrFile)))) {
373+
$options[CURLOPT_CAPATH] = $caPathOrFile;
374+
} else {
375+
$options[CURLOPT_CAINFO] = $caPathOrFile;
376+
}
377+
}
378+
370379
return $options;
371380
}
372381

0 commit comments

Comments
 (0)