1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

API: Fix HTTPS callback issue using SNI in TLS client handshake. v4.0.270, v5.0.168, v6.0.61 (#3695)

---------

Co-authored-by: chundonglinlin <chundonglinlin@163.com>
This commit is contained in:
john 2023-07-21 11:21:06 +08:00 committed by GitHub
parent 3fa4f66648
commit b5f50f3bf4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 6 deletions

View file

@ -9,6 +9,6 @@
#define VERSION_MAJOR 4
#define VERSION_MINOR 0
#define VERSION_REVISION 269
#define VERSION_REVISION 270
#endif

View file

@ -9,6 +9,6 @@
#define VERSION_MAJOR 5
#define VERSION_MINOR 0
#define VERSION_REVISION 167
#define VERSION_REVISION 168
#endif

View file

@ -9,6 +9,6 @@
#define VERSION_MAJOR 6
#define VERSION_MINOR 0
#define VERSION_REVISION 60
#define VERSION_REVISION 61
#endif

View file

@ -56,7 +56,7 @@ SrsSslClient::~SrsSslClient()
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
srs_error_t SrsSslClient::handshake()
srs_error_t SrsSslClient::handshake(const std::string& host)
{
srs_error_t err = srs_success;
@ -88,6 +88,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); ERR_clear_error();
@ -468,7 +472,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));

View file

@ -43,7 +43,7 @@ public:
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);