commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / vendor / totten / ca-config / README.md
1 CA_Config is a small PHP library for determining a default
2 certificate-authority configuration for use by PHP's HTTP/SSL clients.
3
4 ### Examples
5
6 ```php
7 <?php
8
9 // For CURL
10 $caConfig = CA_Config_Curl::singleton();
11 if ($caConfig->isEnableSSL()) {
12 $ch = curl_init();
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);
19 } else {
20 printf("This system does not support SSL.");
21 }
22
23
24 // For PHP Streams
25 $caConfig = CA_Config_Stream::singleton();
26 if ($caConfig->isEnableSSL()) {
27 $context = stream_context_create(array(
28 'ssl' => $caConfig->toStreamOptions(),
29 ));
30 $data = file_get_contents('https://example.com/', 0, $context);
31 } else {
32 printf("This system does not support SSL.");
33 }
34 ```
35
36 ### Helpers
37
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.
42
43 ### Testing
44
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.
49
50 If you encounter problems, feel free to submit a patch or to report the
51 problem.