Commit e291cf62 authored by Yiming Jing's avatar Yiming Jing

mesalink: client_auth bugfix

parent 024c9698
...@@ -67,12 +67,11 @@ static int ParseSSLProtocols(const std::string& str_protocol) { ...@@ -67,12 +67,11 @@ 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(ERROR) << "Uunsupported SSL/TLS protocol=" << protocol;
} else if (strncasecmp(protocol.data(), "TLSv1.1", protocol.size()) == 0) { return -1;
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 +243,6 @@ static int LoadCertificate(SSL_CTX* ctx, ...@@ -244,8 +243,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 +251,8 @@ static int SetSSLOptions(SSL_CTX* ctx, const std::string& ciphers, ...@@ -254,6 +251,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