Verified Commit 81969ae7 authored by Richard Weinhold's avatar Richard Weinhold 🔨

adds support for (suggested) composer/ca-bundle package

parent dbeb4e68
......@@ -20,6 +20,10 @@
"ext-curl": "*"
},
"require-dev": {
"overtrue/phplint": "^2.0"
"overtrue/phplint": "^2.0",
"composer/ca-bundle": "^1.2"
},
"suggest": {
"composer/ca-bundle": "Provides easy solution for system CA certificates."
}
}
......@@ -53,7 +53,12 @@ class APNS extends Handler
$this->certPath = $certPath;
$this->certPassphrase = $certPassphrase;
$this->timeout = $timeout;
$this->caCertPath = $caCertPath;
if ($caCertPath !== null) {
$this->caCertPath = $caCertPath;
} elseif (class_exists('\Composer\CaBundle\CaBundle')) {
$this->caCertPath = \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath();
}
}
public function addDevice(string $token): void
......@@ -128,7 +133,12 @@ class APNS extends Handler
if ($caCertPath === null || !file_exists($caCertPath) || !is_readable($caCertPath)) {
throw new RuntimeException("[APNS] CA not found or not readable for path: {$this->caCertPath}", 404);
}
$options[CURLOPT_CAINFO] = $caCertPath;
if (is_dir($caCertPath)) {
$options[CURLOPT_CAPATH] = $caCertPath;
} else {
$options[CURLOPT_CAINFO] = $caCertPath;
}
}
$curl = curl_init();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment