Unverified Commit 3747d4cf authored by Ge Jun's avatar Ge Jun Committed by GitHub

Merge pull request #883 from mesalock-linux/yj_mesalink_client_auth_fix

mesalink: bug fix for client authentication
parents 23bf4b79 8aeaf2b8
...@@ -67,12 +67,10 @@ static int ParseSSLProtocols(const std::string& str_protocol) { ...@@ -67,12 +67,10 @@ static int ParseSSLProtocols(const std::string& str_protocol) {
for (; sp; ++sp) { for (; sp; ++sp) {
butil::StringPiece protocol(sp.field(), sp.length()); butil::StringPiece protocol(sp.field(), sp.length());
protocol.trim_spaces(); protocol.trim_spaces();
if (strncasecmp(protocol.data(), "SSLv3", protocol.size()) == 0) { if (strncasecmp(protocol.data(), "SSLv3", protocol.size()) == 0
protocol_flag |= SSLv3; || strncasecmp(protocol.data(), "TLSv1", protocol.size()) == 0
} else if (strncasecmp(protocol.data(), "TLSv1", protocol.size()) == 0) { || strncasecmp(protocol.data(), "TLSv1.1", protocol.size()) == 0) {
protocol_flag |= TLSv1; LOG(WARNING) << "Ignored insecure SSL/TLS protocol=" << protocol;
} else if (strncasecmp(protocol.data(), "TLSv1.1", protocol.size()) == 0) {
protocol_flag |= TLSv1_1;
} else if (strncasecmp(protocol.data(), "TLSv1.2", protocol.size()) == 0) { } else if (strncasecmp(protocol.data(), "TLSv1.2", protocol.size()) == 0) {
protocol_flag |= TLSv1_2; protocol_flag |= TLSv1_2;
} else { } else {
...@@ -244,8 +242,6 @@ static int LoadCertificate(SSL_CTX* ctx, ...@@ -244,8 +242,6 @@ static int LoadCertificate(SSL_CTX* ctx,
static int SetSSLOptions(SSL_CTX* ctx, const std::string& ciphers, static int SetSSLOptions(SSL_CTX* ctx, const std::string& ciphers,
int protocols, const VerifyOptions& verify) { int protocols, const VerifyOptions& verify) {
if (verify.verify_depth > 0) { if (verify.verify_depth > 0) {
SSL_CTX_set_verify(ctx, (SSL_VERIFY_PEER
| SSL_VERIFY_FAIL_IF_NO_PEER_CERT), NULL);
std::string cafile = verify.ca_file_path; std::string cafile = verify.ca_file_path;
if (!cafile.empty()) { if (!cafile.empty()) {
if (SSL_CTX_load_verify_locations(ctx, cafile.c_str(), NULL) == 0) { if (SSL_CTX_load_verify_locations(ctx, cafile.c_str(), NULL) == 0) {
...@@ -254,6 +250,8 @@ static int SetSSLOptions(SSL_CTX* ctx, const std::string& ciphers, ...@@ -254,6 +250,8 @@ static int SetSSLOptions(SSL_CTX* ctx, const std::string& ciphers,
return -1; return -1;
} }
} }
SSL_CTX_set_verify(ctx, (SSL_VERIFY_PEER
| SSL_VERIFY_FAIL_IF_NO_PEER_CERT), NULL);
} else { } else {
SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL); SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment