Skip to content

Commit

Permalink
SERVER-13573 Fix x.509 auth exception
Browse files Browse the repository at this point in the history
  • Loading branch information
agralius committed Apr 29, 2014
1 parent 6d255ac commit c151e06
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/mongo/db/commands/authentication_commands.cpp
Expand Up @@ -303,14 +303,18 @@ namespace mongo {
}
else {
std::string srvSubjectName = getSSLManager()->getServerSubjectName();
std::string srvClusterId = srvSubjectName.substr(srvSubjectName.find(",OU="));
std::string peerClusterId = subjectName.substr(subjectName.find(",OU="));

size_t srvClusterIdPos = srvSubjectName.find(",OU=");
size_t peerClusterIdPos = subjectName.find(",OU=");

fassert(17002, !srvClusterId.empty() && srvClusterId != srvSubjectName);
std::string srvClusterId = srvClusterIdPos != std::string::npos ?
srvSubjectName.substr(srvClusterIdPos) : "";
std::string peerClusterId = peerClusterIdPos != std::string::npos ?
subjectName.substr(peerClusterIdPos) : "";

// Handle internal cluster member auth, only applies to server-server connections
int clusterAuthMode = serverGlobalParams.clusterAuthMode.load();
if (srvClusterId == peerClusterId) {
if (srvClusterId == peerClusterId && !srvClusterId.empty()) {
if (clusterAuthMode == ServerGlobalParams::ClusterAuthMode_undefined ||
clusterAuthMode == ServerGlobalParams::ClusterAuthMode_keyFile) {
return Status(ErrorCodes::AuthenticationFailed, "The provided certificate "
Expand Down

0 comments on commit c151e06

Please sign in to comment.