SSL peer match name case-insensitive

pull/22443/head
jiangtaoli2016 5 years ago
parent f1f0003a4c
commit 4d41a56e17
  1. 6
      src/core/tsi/ssl_transport_security.cc
  2. 3
      test/core/tsi/ssl_transport_security_test.cc

@ -35,6 +35,8 @@
#include <sys/socket.h>
#endif
#include "absl/strings/match.h"
#include <grpc/grpc_security.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@ -1658,7 +1660,7 @@ static int does_entry_match_name(grpc_core::StringView entry,
if (entry.empty()) return 0;
}
if (name == entry) {
if (absl::EqualsIgnoreCase(name, entry)) {
return 1; /* Perfect match. */
}
if (entry.front() != '*') return 0;
@ -1685,7 +1687,7 @@ static int does_entry_match_name(grpc_core::StringView entry,
if (name_subdomain.back() == '.') {
name_subdomain.remove_suffix(1);
}
return !entry.empty() && name_subdomain == entry;
return !entry.empty() && absl::EqualsIgnoreCase(name_subdomain, entry);
}
static int ssl_server_handshaker_factory_servername_callback(SSL* ssl,

@ -235,6 +235,9 @@ void check_server0_peer(tsi_peer* peer) {
nullptr);
GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "foo.test.google.com.au") == 1);
GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "bar.test.google.com.au") == 1);
GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "BAR.TEST.GOOGLE.COM.AU") == 1);
GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "Bar.Test.Google.Com.Au") == 1);
GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "bAr.TeST.gOOgle.cOm.AU") == 1);
GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "bar.test.google.blah") == 0);
GPR_ASSERT(tsi_ssl_peer_matches_name(peer, "foo.bar.test.google.com.au") ==
0);

Loading…
Cancel
Save