Last active
September 14, 2015 14:31
-
-
Save phpdave/8d594cfcfd6c11e704af to your computer and use it in GitHub Desktop.
Pseudo code for detecting php version, operating system and a default location for CA bundle.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$os = php_uname("s"); | |
$phpversion = floatval(substr(phpversion (),0,3)); | |
if($phpversion<5.6) | |
{ | |
if($os=="OS400") | |
{ | |
$defaultcafile = "/QOpenSys/QIBM/ProdData/SC1/OpenSSL/openssl-0.9.7d/cert.pem"; | |
} | |
else if ($os=="Linux") | |
{ | |
$defaultcafile = "/etc/pki/tls/certs/ca-bundle.crt"; | |
} | |
} | |
if(!file_exists($defaultcafile) && $userDidntProvideCABundle) | |
{ | |
//possible security issue as you have to trust that the DNS and server below is not compromised. | |
$certFromWeb = readfile("http://curl.haxx.se/ca/cacert.pem"); | |
//::TODO:: cache this cert so we don't send multiple requests. Have to add logic above to see if we have the cached cert | |
$defaultcafile = $certFromWeb; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment