Skip to content

Commit

Permalink
API: Fix HTTPS callback issue using SNI in TLS client handshake. v4.0…
Browse files Browse the repository at this point in the history
….270 (ossrs#3695)

---------

Co-authored-by: chundonglinlin <chundonglinlin@163.com>
  • Loading branch information
2 people authored and winlinvip committed Jul 21, 2023
1 parent 55ca61e commit 4e94300
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions trunk/doc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The changelog for SRS.

## SRS 4.0 Changelog

* v4.0, 2023-07-21, Merge [#3695](https://github.com/ossrs/srs/pull/3695): API: Fix HTTPS callback issue using SNI in TLS client handshake. v4.0.270 (#3695)
* v4.0, 2022-12-24, For [#296](https://github.com/ossrs/srs/issues/296): MP3: Fix bug for TS or HLS with mp3 codec. v4.0.269
* v4.0, 2022-11-22, Pick [#3079](https://github.com/ossrs/srs/issues/3079): WebRTC: Fix no audio and video issue for Firefox. v4.0.268
* v4.0, 2022-10-10, For [#2901](https://github.com/ossrs/srs/issues/2901): Edge: Fast disconnect and reconnect. v4.0.267
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/core/srs_core_version4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

#define VERSION_MAJOR 4
#define VERSION_MINOR 0
#define VERSION_REVISION 269
#define VERSION_REVISION 270

#endif
8 changes: 6 additions & 2 deletions trunk/src/protocol/srs_service_http_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ SrsSslClient::~SrsSslClient()
}
}

srs_error_t SrsSslClient::handshake()
srs_error_t SrsSslClient::handshake(const std::string& host)
{
srs_error_t err = srs_success;

Expand Down Expand Up @@ -86,6 +86,10 @@ srs_error_t SrsSslClient::handshake()
// SSL setup active, as client role.
SSL_set_connect_state(ssl);
SSL_set_mode(ssl, SSL_MODE_ENABLE_PARTIAL_WRITE);
// If the server address is not in IP address format, set the host in the Server Name Indication (SNI) field.
if (!srs_check_ip_addr_valid(host)) {
SSL_set_tlsext_host_name(ssl, host.c_str());
}

// Send ClientHello.
int r0 = SSL_do_handshake(ssl); int r1 = SSL_get_error(ssl, r0);
Expand Down Expand Up @@ -465,7 +469,7 @@ srs_error_t SrsHttpClient::connect()

srs_utime_t starttime = srs_update_system_time();

if ((err = ssl_transport->handshake()) != srs_success) {
if ((err = ssl_transport->handshake(host)) != 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));
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/protocol/srs_service_http_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class SrsSslClient : public ISrsReader, public ISrsStreamWriter
SrsSslClient(SrsTcpClient* tcp);
virtual ~SrsSslClient();
public:
virtual srs_error_t handshake();
virtual srs_error_t handshake(const std::string& host);
public:
virtual srs_error_t read(void* buf, size_t size, ssize_t* nread);
virtual srs_error_t write(void* buf, size_t size, ssize_t* nwrite);
Expand Down

0 comments on commit 4e94300

Please sign in to comment.