private function Client::getCaBundle in Smart IP 7.2
Same name and namespace in other branches
- 6.2 includes/vendor/maxmind/web-service-common/src/WebService/Client.php \MaxMind\WebService\Client::getCaBundle()
1 call to Client::getCaBundle()
- Client::__construct in includes/
vendor/ maxmind/ web-service-common/ src/ WebService/ Client.php
File
- includes/
vendor/ maxmind/ web-service-common/ src/ WebService/ Client.php, line 414
Class
- Client
- This class is not intended to be used directly by an end-user of a MaxMind web service. Please use the appropriate client API for the service that you are using. @package MaxMind\WebService @internal
Namespace
MaxMind\WebServiceCode
private function getCaBundle() {
$cert = CaBundle::getSystemCaRootBundlePath();
// Check if the cert is inside a phar. If so, we need to copy the cert
// to a temp file so that curl can see it.
if (substr($cert, 0, 7) == 'phar://') {
$tempDir = sys_get_temp_dir();
$newCert = tempnam($tempDir, 'geoip2-');
if ($newCert === false) {
throw new \RuntimeException("Unable to create temporary file in {$tempDir}");
}
if (!copy($cert, $newCert)) {
throw new \RuntimeException("Could not copy {$cert} to {$newCert}: " . var_export(error_get_last(), true));
}
// We use a shutdown function rather than the destructor as the
// destructor isn't called on a fatal error such as an uncaught
// exception.
register_shutdown_function(function () use ($newCert) {
unlink($newCert);
});
$cert = $newCert;
}
if (!file_exists($cert)) {
throw new \RuntimeException("CA cert does not exist at {$cert}");
}
return $cert;
}