|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace LiquidWeb\SslCertificate; |
|
4
|
|
|
|
|
5
|
|
|
class StreamConfig |
|
6
|
|
|
{ |
|
7
|
|
|
/** |
|
8
|
|
|
* The stream settings for the client. |
|
9
|
|
|
* |
|
10
|
|
|
* @return A stream context resource. |
|
11
|
|
|
*/ |
|
12
|
|
|
protected $streamContext; |
|
13
|
|
|
|
|
14
|
12 |
|
public static function configSecure(): self |
|
15
|
|
|
{ |
|
16
|
12 |
|
$streamContext = stream_context_create( |
|
17
|
|
|
[ |
|
18
|
12 |
|
'ssl' => [ |
|
19
|
|
|
'capture_peer_cert' => true, |
|
20
|
|
|
'capture_peer_cert_chain' => true, |
|
21
|
|
|
'disable_compression' => true, |
|
22
|
|
|
], |
|
23
|
|
|
] |
|
24
|
|
|
); |
|
25
|
|
|
|
|
26
|
12 |
|
return new static($streamContext); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
8 |
|
public static function configInsecure(): self |
|
30
|
|
|
{ |
|
31
|
8 |
|
$streamContext = stream_context_create( |
|
32
|
|
|
[ |
|
33
|
8 |
|
'ssl' => [ |
|
34
|
|
|
'allow_self_signed' => true, |
|
35
|
|
|
'verify_peer' => false, |
|
36
|
|
|
'verify_peer_name' => false, |
|
37
|
|
|
'capture_peer_cert' => true, |
|
38
|
|
|
'capture_peer_cert_chain' => true, |
|
39
|
|
|
'disable_compression' => true, |
|
40
|
|
|
], |
|
41
|
|
|
] |
|
42
|
|
|
); |
|
43
|
|
|
|
|
44
|
8 |
|
return new static($streamContext); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
2 |
|
public static function configCrl(): self |
|
48
|
|
|
{ |
|
49
|
2 |
|
$streamContext = stream_context_create( |
|
50
|
|
|
[ |
|
51
|
2 |
|
'http' => [ |
|
52
|
|
|
'method' => 'GET', |
|
53
|
|
|
'max_redirects' => '0', |
|
54
|
|
|
'ignore_errors' => '1', |
|
55
|
|
|
], |
|
56
|
|
|
] |
|
57
|
|
|
); |
|
58
|
|
|
|
|
59
|
2 |
|
return new static($streamContext); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
13 |
|
public function __construct($streamContext) |
|
63
|
|
|
{ |
|
64
|
13 |
|
$this->streamContext = $streamContext; |
|
65
|
13 |
|
} |
|
66
|
|
|
|
|
67
|
13 |
|
public function getContext() |
|
68
|
|
|
{ |
|
69
|
13 |
|
return $this->streamContext; |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|