mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
SSL: Fix SSL_get_error get the error of other coroutine. v5.0.155, v6.0.46 (#3513)
--------- Co-authored-by: john <hondaxiao@tencent.com> Co-authored-by: winlin <winlin@vip.126.com>
This commit is contained in:
parent
665c30af90
commit
27f9db9762
9 changed files with 22 additions and 17 deletions
|
@ -90,7 +90,7 @@ srs_error_t SrsSslClient::handshake()
|
|||
SSL_set_mode(ssl, SSL_MODE_ENABLE_PARTIAL_WRITE);
|
||||
|
||||
// Send ClientHello.
|
||||
int r0 = SSL_do_handshake(ssl); int r1 = SSL_get_error(ssl, r0);
|
||||
int r0 = SSL_do_handshake(ssl); int r1 = SSL_get_error(ssl, r0); ERR_clear_error();
|
||||
if (r0 != -1 || r1 != SSL_ERROR_WANT_READ) {
|
||||
return srs_error_new(ERROR_HTTPS_HANDSHAKE, "handshake r0=%d, r1=%d", r0, r1);
|
||||
}
|
||||
|
@ -121,7 +121,8 @@ srs_error_t SrsSslClient::handshake()
|
|||
return srs_error_new(ERROR_HTTPS_HANDSHAKE, "BIO_write r0=%d, data=%p, size=%d", r0, buf, nn);
|
||||
}
|
||||
|
||||
if ((r0 = SSL_do_handshake(ssl)) != -1 || (r1 = SSL_get_error(ssl, r0)) != SSL_ERROR_WANT_READ) {
|
||||
r0 = SSL_do_handshake(ssl); r1 = SSL_get_error(ssl, r0); ERR_clear_error();
|
||||
if (r0 != -1 || r1 != SSL_ERROR_WANT_READ) {
|
||||
return srs_error_new(ERROR_HTTPS_HANDSHAKE, "handshake r0=%d, r1=%d", r0, r1);
|
||||
}
|
||||
|
||||
|
@ -159,7 +160,7 @@ srs_error_t SrsSslClient::handshake()
|
|||
return srs_error_new(ERROR_HTTPS_HANDSHAKE, "BIO_write r0=%d, data=%p, size=%d", r0, buf, nn);
|
||||
}
|
||||
|
||||
r0 = SSL_do_handshake(ssl); r1 = SSL_get_error(ssl, r0);
|
||||
r0 = SSL_do_handshake(ssl); r1 = SSL_get_error(ssl, r0); ERR_clear_error();
|
||||
if (r0 == 1 && r1 == SSL_ERROR_NONE) {
|
||||
break;
|
||||
}
|
||||
|
@ -180,7 +181,7 @@ srs_error_t SrsSslClient::read(void* plaintext, size_t nn_plaintext, ssize_t* nr
|
|||
srs_error_t err = srs_success;
|
||||
|
||||
while (true) {
|
||||
int r0 = SSL_read(ssl, plaintext, nn_plaintext); int r1 = SSL_get_error(ssl, r0);
|
||||
int r0 = SSL_read(ssl, plaintext, nn_plaintext); int r1 = SSL_get_error(ssl, r0); ERR_clear_error();
|
||||
int r2 = BIO_ctrl_pending(bio_in); int r3 = SSL_is_init_finished(ssl);
|
||||
|
||||
// OK, got data.
|
||||
|
@ -228,7 +229,7 @@ srs_error_t SrsSslClient::write(void* plaintext, size_t nn_plaintext, ssize_t* n
|
|||
for (char* p = (char*)plaintext; p < (char*)plaintext + nn_plaintext;) {
|
||||
int left = (int)nn_plaintext - (p - (char*)plaintext);
|
||||
int r0 = SSL_write(ssl, (const void*)p, left);
|
||||
int r1 = SSL_get_error(ssl, r0);
|
||||
int r1 = SSL_get_error(ssl, r0); ERR_clear_error();
|
||||
if (r0 <= 0) {
|
||||
return srs_error_new(ERROR_HTTPS_WRITE, "https: write data=%p, size=%d, r0=%d, r1=%d", p, left, r0, r1);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <map>
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/err.h>
|
||||
|
||||
#include <srs_protocol_st.hpp>
|
||||
#include <srs_protocol_http_stack.hpp>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue