File tree 2 files changed +29
-2
lines changed
2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -131,7 +131,7 @@ The same mechanic is offered to perform `PUT` and `PATCH` requests wich all are
131
131
132
132
The following example shows the usage with a more detailed configuration.
133
133
134
- #### Configuring a HTTP Transport instance
134
+ #### Configuring an HTTP Transport instance
135
135
136
136
``` {php}
137
137
use ChromaX\BasicHttpClient\Request\Transport\HttpTransport;
@@ -147,7 +147,7 @@ $transport
147
147
->setMaxRedirects(10);
148
148
```
149
149
150
- #### Configuring a HTTPS Transport instance
150
+ #### Configuring an HTTPS Transport instance
151
151
152
152
``` {php}
153
153
use ChromaX\BasicHttpClient\Request\Transport\HttpsTransport;
@@ -161,6 +161,7 @@ $transport
161
161
->setAllowCaching(true)
162
162
->setFollowRedirects(true)
163
163
->setMaxRedirects(10)
164
+ ->setVerifyHost(true)
164
165
->setVerifyPeer(true);
165
166
```
166
167
Original file line number Diff line number Diff line change 10
10
class HttpsTransport extends HttpTransport
11
11
{
12
12
13
+ /**
14
+ * Whether to verify the peer SSL certificate
15
+ *
16
+ * @var bool
17
+ */
18
+ protected $ verifyHost = true ;
19
+
13
20
/**
14
21
* Whether to verify the peer SSL certificate
15
22
*
16
23
* @var bool
17
24
*/
18
25
protected $ verifyPeer = true ;
19
26
27
+ /**
28
+ * @return bool
29
+ */
30
+ public function getVerifyHost (): bool
31
+ {
32
+ return $ this ->verifyHost ;
33
+ }
34
+
35
+ /**
36
+ * @param bool $verifyHost
37
+ */
38
+ public function setVerifyHost (bool $ verifyHost )
39
+ {
40
+ $ this ->verifyHost = $ verifyHost ;
41
+ return $ this ;
42
+ }
43
+
20
44
/**
21
45
* @return bool
22
46
*/
@@ -42,6 +66,8 @@ public function setVerifyPeer(bool $verifyPeer)
42
66
public function configureCurl ($ curl )
43
67
{
44
68
parent ::configureCurl ($ curl );
69
+ // Verify host
70
+ curl_setopt ($ curl , CURLOPT_SSL_VERIFYHOST , $ this ->verifyHost ? 2 : 0 );
45
71
// Verify peer
46
72
curl_setopt ($ curl , CURLOPT_SSL_VERIFYPEER , $ this ->verifyPeer );
47
73
return $ this ;
You can’t perform that action at this time.
0 commit comments