@@ -75,7 +75,7 @@ TEST_FIXTURE(uri_address, outside_wikipedia_compressed_http_response)
75
75
76
76
auto s = response.extract_utf8string ().get ();
77
77
VERIFY_IS_FALSE (s.empty ());
78
-
78
+
79
79
utility::string_t encoding;
80
80
VERIFY_IS_TRUE (response.headers ().match (web::http::header_names::content_encoding, encoding));
81
81
@@ -93,14 +93,14 @@ TEST_FIXTURE(uri_address, outside_google_dot_com)
93
93
VERIFY_ARE_EQUAL (status_codes::OK, response.status_code ());
94
94
}
95
95
}
96
-
96
+
97
97
TEST_FIXTURE (uri_address, multiple_https_requests)
98
98
{
99
99
handle_timeout ([&]
100
100
{
101
101
// Use code.google.com instead of www.google.com, which redirects
102
102
http_client client (U (" https://code.google.com" ));
103
-
103
+
104
104
http_response response;
105
105
for (int i = 0 ; i < 5 ; ++i)
106
106
{
@@ -155,38 +155,90 @@ TEST_FIXTURE(uri_address, no_transfer_encoding_content_length)
155
155
// https://www.ssllabs.com/ssltest/
156
156
// http://www.internetsociety.org/deploy360/resources/dane-test-sites/
157
157
// https://onlinessl.netlock.hu/#
158
- TEST (server_selfsigned_cert )
158
+ static void test_failed_ssl_cert ( const uri& base_uri )
159
159
{
160
- handle_timeout ([]
160
+ handle_timeout ([&base_uri ]
161
161
{
162
- http_client client (U ( " https://self-signed.badssl.com/ " ) );
162
+ http_client client (base_uri );
163
163
auto requestTask = client.request (methods::GET);
164
164
VERIFY_THROWS (requestTask.get (), http_exception);
165
165
});
166
166
}
167
167
168
- TEST (server_hostname_mismatch)
168
+ #if !defined(__cplusplus_winrt)
169
+ static void test_ignored_ssl_cert (const uri& base_uri)
169
170
{
170
- handle_timeout ([]
171
+ handle_timeout ([&base_uri ]
171
172
{
172
- http_client client (U (" https://wrong.host.badssl.com/" ));
173
- auto requestTask = client.request (methods::GET);
174
- VERIFY_THROWS (requestTask.get (), http_exception);
173
+ http_client_config config;
174
+ config.set_validate_certificates (false );
175
+ http_client client (base_uri, config);
176
+ auto request = client.request (methods::GET).get ();
177
+ VERIFY_ARE_EQUAL (status_codes::OK, request.status_code ());
175
178
});
176
179
}
180
+ #endif // !defined(__cplusplus_winrt)
181
+
182
+ TEST (server_selfsigned_cert)
183
+ {
184
+ test_failed_ssl_cert (U (" https://self-signed.badssl.com/" ));
185
+ }
186
+
187
+ #if !defined(__cplusplus_winrt)
188
+ TEST (server_selfsigned_cert_ignored)
189
+ {
190
+ test_ignored_ssl_cert (U (" https://self-signed.badssl.com/" ));
191
+ }
192
+ #endif // !defined(__cplusplus_winrt)
193
+
194
+ TEST (server_hostname_mismatch)
195
+ {
196
+ test_failed_ssl_cert (U (" https://wrong.host.badssl.com/" ));
197
+ }
198
+
199
+ #if !defined(__cplusplus_winrt)
200
+ TEST (server_hostname_mismatch_ignored)
201
+ {
202
+ test_ignored_ssl_cert (U (" https://wrong.host.badssl.com/" ));
203
+ }
204
+ #endif // !defined(__cplusplus_winrt)
177
205
178
206
TEST (server_cert_expired)
179
207
{
180
- handle_timeout ([]
181
- {
182
- http_client_config config;
183
- config.set_timeout (std::chrono::seconds (1 ));
184
- http_client client (U (" https://expired.badssl.com/" ), config);
185
- auto requestTask = client.request (methods::GET);
186
- VERIFY_THROWS (requestTask.get (), http_exception);
187
- });
208
+ test_failed_ssl_cert (U (" https://expired.badssl.com/" ));
209
+ }
210
+
211
+ #if !defined(__cplusplus_winrt)
212
+ TEST (server_cert_expired_ignored)
213
+ {
214
+ test_ignored_ssl_cert (U (" https://expired.badssl.com/" ));
215
+ }
216
+ #endif // !defined(__cplusplus_winrt)
217
+
218
+ TEST (server_cert_revoked)
219
+ {
220
+ test_failed_ssl_cert (U (" https://revoked.badssl.com/" ));
221
+ }
222
+
223
+ #if !defined(__cplusplus_winrt)
224
+ TEST (server_cert_revoked_ignored)
225
+ {
226
+ test_ignored_ssl_cert (U (" https://revoked.badssl.com/" ));
227
+ }
228
+ #endif // !defined(__cplusplus_winrt)
229
+
230
+ TEST (server_cert_untrusted)
231
+ {
232
+ test_failed_ssl_cert (U (" https://untrusted-root.badssl.com/" ));
188
233
}
189
234
235
+ #if !defined(__cplusplus_winrt)
236
+ TEST (server_cert_untrusted_ignored)
237
+ {
238
+ test_ignored_ssl_cert (U (" https://untrusted-root.badssl.com/" ));
239
+ }
240
+ #endif // !defined(__cplusplus_winrt)
241
+
190
242
#if !defined(__cplusplus_winrt)
191
243
TEST (ignore_server_cert_invalid,
192
244
" Ignore:Android" , " 229" ,
@@ -204,7 +256,7 @@ TEST(ignore_server_cert_invalid,
204
256
VERIFY_ARE_EQUAL (status_codes::OK, request.status_code ());
205
257
});
206
258
}
207
- #endif
259
+ #endif // !defined(__cplusplus_winrt)
208
260
209
261
TEST_FIXTURE (uri_address, outside_ssl_json)
210
262
{
0 commit comments