This is an automated email from the ASF dual-hosted git repository. lorinlee pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git
The following commit(s) were added to refs/heads/master by this push: new d5ab6ac8 fix issue of ssl error code new 0c58ead5 Merge pull request #2019 from yyweii/wyy-ssl d5ab6ac8 is described below commit d5ab6ac8d69c6d5e20e7260687d1794aae955c91 Author: yyweii <thym...@gmail.com> AuthorDate: Sat Nov 26 20:59:22 2022 +0800 fix issue of ssl error code --- src/brpc/details/ssl_helper.cpp | 2 +- src/brpc/socket.cpp | 3 ++- src/butil/iobuf.cpp | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/brpc/details/ssl_helper.cpp b/src/brpc/details/ssl_helper.cpp index 1495a719..effba37e 100644 --- a/src/brpc/details/ssl_helper.cpp +++ b/src/brpc/details/ssl_helper.cpp @@ -350,7 +350,7 @@ static int LoadCertificate(SSL_CTX* ctx, if (err != 0 && (ERR_GET_LIB(err) != ERR_LIB_PEM || ERR_GET_REASON(err) != PEM_R_NO_START_LINE)) { LOG(ERROR) << "Fail to read chain certificate in " - << certificate << ": " << SSLError(ERR_get_error()); + << certificate << ": " << SSLError(err); return -1; } ERR_clear_error(); diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index e5097f90..b4dc734e 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -1836,7 +1836,7 @@ ssize_t Socket::DoWrite(WriteRequest* req) { const unsigned long e = ERR_get_error(); if (e != 0) { LOG(WARNING) << "Fail to write into ssl_fd=" << fd() << ": " - << SSLError(ERR_get_error()); + << SSLError(e); errno = ESSL; } else { // System error with corresponding errno set @@ -1879,6 +1879,7 @@ int Socket::SSLHandshake(int fd, bool server_mode) { // we use bthread_fd_wait as polling mechanism instead of EventDispatcher // as it may confuse the origin event processing code. while (true) { + ERR_clear_error(); int rc = SSL_do_handshake(_ssl_session); if (rc == 1) { _ssl_state = SSL_CONNECTED; diff --git a/src/butil/iobuf.cpp b/src/butil/iobuf.cpp index b468e91d..b92b909b 100644 --- a/src/butil/iobuf.cpp +++ b/src/butil/iobuf.cpp @@ -19,6 +19,7 @@ // Date: Thu Nov 22 13:57:56 CST 2012 +#include <openssl/err.h> #include <openssl/ssl.h> // SSL_* #ifdef USE_MESALINK #include <mesalink/openssl/ssl.h> @@ -977,6 +978,7 @@ ssize_t IOBuf::cut_into_SSL_channel(SSL* ssl, int* ssl_error) { } IOBuf::BlockRef const& r = _ref_at(0); + ERR_clear_error(); const int nw = SSL_write(ssl, r.block->data + r.offset, r.length); if (nw > 0) { pop_front(nw); @@ -1679,6 +1681,7 @@ ssize_t IOPortal::append_from_SSL_channel( } const size_t read_len = std::min(_block->left_space(), max_count - nr); + ERR_clear_error(); const int rc = SSL_read(ssl, _block->data + _block->size, read_len); *ssl_error = SSL_get_error(ssl, rc); if (rc > 0) { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For additional commands, e-mail: dev-h...@brpc.apache.org