Skip to content

Commit

Permalink
For #1657, Refine https-client code
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Nov 3, 2020
1 parent d552a1a commit 5577d19
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions trunk/src/protocol/srs_service_http_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ srs_error_t SrsSslClient::handshake()
return srs_error_new(ERROR_HTTPS_HANDSHAKE, "BIO_reset r0=%d", r0);
}

srs_trace("https: ClientHello done");
srs_info("https: ClientHello done");

// Receive ServerHello, Certificate, Server Key Exchange, Server Hello Done
while (true) {
Expand All @@ -145,7 +145,7 @@ srs_error_t SrsSslClient::handshake()
}
}

srs_trace("https: ServerHello done");
srs_info("https: ServerHello done");

// Send Client Key Exchange, Change Cipher Spec, Encrypted Handshake Message
if ((err = transport->write(data, size, NULL)) != srs_success) {
Expand All @@ -155,7 +155,7 @@ srs_error_t SrsSslClient::handshake()
return srs_error_new(ERROR_HTTPS_HANDSHAKE, "BIO_reset r0=%d", r0);
}

srs_trace("https: Client done");
srs_info("https: Client done");

// Receive New Session Ticket, Change Cipher Spec, Encrypted Handshake Message
while (true) {
Expand All @@ -180,7 +180,7 @@ srs_error_t SrsSslClient::handshake()
}
}

srs_trace("https: Server done");
srs_info("https: Server done");

return err;
}
Expand Down Expand Up @@ -460,12 +460,17 @@ srs_error_t SrsHttpClient::connect()
srs_assert(!ssl_transport);
ssl_transport = new SrsSslClient(transport);

srs_utime_t starttime = srs_update_system_time();

if ((err = ssl_transport->handshake()) != srs_success) {
disconnect();
return srs_error_wrap(err, "http: ssl connect %s %s:%d to=%dms, rto=%dms",
schema_.c_str(), host.c_str(), port, srsu2msi(timeout), srsu2msi(recv_timeout));
}

int cost = srsu2msi(srs_update_system_time() - starttime);
srs_trace("https: connected to %s://%s:%d, cost=%dms", schema_.c_str(), host.c_str(), port, cost);

return err;
#endif
}
Expand Down

0 comments on commit 5577d19

Please sign in to comment.