Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 79 lines (71 sloc) 2.19 kB
b8d05f3 @boenrobot Initial version.
boenrobot authored
1 <?php
4b9d231 @boenrobot Changed ServerTest.php to only have 10min timeout;
boenrobot authored
2
3 /**
4 * bootstrap.php for PEAR2_Net_Transmitter.
5 *
6 * PHP version 5
7 *
8 * @category Net
9 * @package PEAR2_Net_Transmitter
10 * @author Vasil Rangelov <boen.robot@gmail.com>
11 * @copyright 2011 Vasil Rangelov
12 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
13 * @version GIT: $Id$
14 * @link http://pear2.php.net/PEAR2_Net_Transmitter
15 */
16
17 /**
18 * Possible autoloader to initialize.
19 */
20 use PEAR2\Autoload;
21
22 chdir(__DIR__);
23
24 $autoloader = stream_resolve_include_path('../vendor/autoload.php');
c8812d8 @boenrobot Added $fragment to SocketException, and made receiving fill it with t…
boenrobot authored
25 if (false !== $autoloader) {
26 include_once $autoloader;
ffe0341 @boenrobot First implementation of encrypted connections.
boenrobot authored
27 } else {
c8812d8 @boenrobot Added $fragment to SocketException, and made receiving fill it with t…
boenrobot authored
28 $autoloader = stream_resolve_include_path('PEAR2/Autoload.php');
29 if (false !== $autoloader) {
30 include_once $autoloader;
4b9d231 @boenrobot Changed ServerTest.php to only have 10min timeout;
boenrobot authored
31 Autoload::initialize(realpath('../src'));
4a09fb0 @boenrobot Fixed the createException() signature compatibility error;
boenrobot authored
32 Autoload::initialize(realpath('../../Cache_SHM.git/src'));
c8812d8 @boenrobot Added $fragment to SocketException, and made receiving fill it with t…
boenrobot authored
33 } else {
4b9d231 @boenrobot Changed ServerTest.php to only have 10min timeout;
boenrobot authored
34 fwrite(STDERR, 'No recognized autoloader is available.');
35 exit(1);
c8812d8 @boenrobot Added $fragment to SocketException, and made receiving fill it with t…
boenrobot authored
36 }
ffe0341 @boenrobot First implementation of encrypted connections.
boenrobot authored
37 }
4b9d231 @boenrobot Changed ServerTest.php to only have 10min timeout;
boenrobot authored
38 unset($autoloader);
c497190 @boenrobot Simplified Stream::isAvaiable() (moved the changes to NetworkStream::…
boenrobot authored
39
40 if (!is_file(__DIR__ . DIRECTORY_SEPARATOR . CERTIFICATE_FILE)) {
41 //Prepare a self signed certificate
42 $configargs = array();
43 if (strpos(PHP_OS, 'WIN') === 0) {
44 $phpbin = defined('PHP_BINARY')
45 ? PHP_BINARY
46 : getenv('PHP_PEAR_PHP_BIN');
47 $configargs['config'] = dirname($phpbin) . '/extras/ssl/openssl.cnf';
48 }
49
50 $privkey = openssl_pkey_new($configargs);
51 $cert = openssl_csr_sign(
52 openssl_csr_new(
53 array(
54 'countryName' => 'US',
55 'stateOrProvinceName' => 'IRRELEVANT',
56 'localityName' => 'IRRELEVANT',
57 'organizationName' => 'PEAR2',
58 'organizationalUnitName' => 'PEAR2',
59 'commonName' => 'IRRELEVANT',
60 'emailAddress' => 'IRRELEVANT@example.com'
61 ),
62 $privkey,
63 $configargs
64 ),
65 null,
66 $privkey,
67 2,
68 $configargs
69 );
70
71 $pem = array();
72 openssl_x509_export($cert, $pem[0]);
73 openssl_pkey_export($privkey, $pem[1], null, $configargs);
74
75 file_put_contents(
76 __DIR__ . DIRECTORY_SEPARATOR . CERTIFICATE_FILE,
77 implode('', $pem)
78 );
79 }
Something went wrong with that request. Please try again.