|
15 | 15 | #include "cpprest/ws_client.h"
|
16 | 16 | #include "nmos/certificate_settings.h"
|
17 | 17 | #include "nmos/json_fields.h"
|
| 18 | +#include "nmos/mdns.h" |
18 | 19 | #include "nmos/slog.h"
|
19 | 20 | #include "nmos/ssl_context_options.h"
|
20 | 21 |
|
@@ -263,14 +264,25 @@ namespace nmos
|
263 | 264 | {
|
264 | 265 | // unstash the host name for the Host header
|
265 | 266 | // cf. nmos::details::resolve_service
|
266 |
| - std::unique_ptr<web::http::client::http_client> client(new web::http::client::http_client(web::uri_builder(base_uri).set_user_info({}).to_uri(), client_config)); |
| 267 | + // Note: in secure mode, use the host name instead of the IP adddress for the host |
| 268 | + web::uri base_uri_{ base_uri }; |
| 269 | + if (!base_uri.user_info().empty() && nmos::is_service_protocol_secure(utility::us2s(base_uri.scheme()))) |
| 270 | + { |
| 271 | + auto host = base_uri.user_info(); |
| 272 | + base_uri_ = web::uri_builder(base_uri).set_user_info({}).set_host(host).to_uri(); |
| 273 | + } |
| 274 | + std::unique_ptr<web::http::client::http_client> client(new web::http::client::http_client(base_uri_, client_config)); |
| 275 | + |
267 | 276 | if (!base_uri.user_info().empty())
|
268 | 277 | {
|
269 | 278 | auto host = base_uri.user_info();
|
270 |
| - if (base_uri.port() > 0) |
271 |
| - { |
272 |
| - host.append(U(":")).append(utility::conversions::details::to_string_t(base_uri.port())); |
273 |
| - } |
| 279 | + |
| 280 | + // hmm, in secure mode, the port number used in the Host header cause SSL handshake Error, disable it for now |
| 281 | + //if (base_uri.port() > 0) |
| 282 | + //{ |
| 283 | + // host.append(U(":")).append(utility::conversions::details::to_string_t(base_uri.port())); |
| 284 | + //} |
| 285 | + |
274 | 286 | client->add_handler([host](web::http::http_request request, std::shared_ptr<web::http::http_pipeline_stage> next_stage) -> pplx::task<web::http::http_response>
|
275 | 287 | {
|
276 | 288 | request.headers().add(web::http::header_names::host, host);
|
|
0 commit comments