1 CA_Config is a small PHP library for determining a default
2 certificate-authority configuration for use by PHP's HTTP/SSL clients.
10 $caConfig = CA_Config_Curl::singleton();
11 if ($caConfig->isEnableSSL()) {
13 curl_setopt($ch, CURLOPT_URL, );
14 curl_setopt($ch, CURLOPT_HEADER, 0);
15 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
16 curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
17 curl_setopt_array($ch, $caConfig->toCurlOptions());
18 $response = curl_exec($ch);
20 printf("This system does not support SSL.");
25 $caConfig = CA_Config_Stream::singleton();
26 if ($caConfig->isEnableSSL()) {
27 $context = stream_context_create(array(
28 'ssl' => $caConfig->toStreamOptions(),
30 $data = file_get_contents('https://example.com/', 0, $context);
32 printf("This system does not support SSL.");
38 When requesting an instance, one can use either singleton() or probe().
39 singleton() is intended for modest apps that don't have a service container.
40 singleton() is just a wrapper for probe() which reads extra configuration
41 options from a global variable and returns a single instance.
45 This has not been tested on a broad range of configurations, and the
46 underlying problem is that CA configurations are not well-standardized in
47 different PHP environments. To determine if this produces a valid
48 configuration in your environment, run the phpunit test suite.
50 If you encounter problems, feel free to submit a patch or to report the