summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/TLS/ServerIdentityVerifier.cpp')
-rw-r--r--Swiften/TLS/ServerIdentityVerifier.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/Swiften/TLS/ServerIdentityVerifier.cpp b/Swiften/TLS/ServerIdentityVerifier.cpp
index 226e94b..da116e5 100644
--- a/Swiften/TLS/ServerIdentityVerifier.cpp
+++ b/Swiften/TLS/ServerIdentityVerifier.cpp
@@ -12,7 +12,7 @@
12 12
13namespace Swift { 13namespace Swift {
14 14
15ServerIdentityVerifier::ServerIdentityVerifier(const JID& jid, IDNConverter* idnConverter) : domainValid(false) { 15ServerIdentityVerifier::ServerIdentityVerifier(const JID& jid, IDNConverter* idnConverter, bool checkServer) : domainValid(false), checkServer_(checkServer) {
16 domain = jid.getDomain(); 16 domain = jid.getDomain();
17 boost::optional<std::string> domainResult = idnConverter->getIDNAEncoded(domain); 17 boost::optional<std::string> domainResult = idnConverter->getIDNAEncoded(domain);
18 if (!!domainResult) { 18 if (!!domainResult) {
@@ -36,12 +36,14 @@ bool ServerIdentityVerifier::certificateVerifies(Certificate::ref certificate) {
36 } 36 }
37 hasSAN |= !dnsNames.empty(); 37 hasSAN |= !dnsNames.empty();
38 38
39 std::string prefix = (checkServer_) ? "_xmpp-server." : "_xmpp-client.";
40
39 // SRV names 41 // SRV names
40 std::vector<std::string> srvNames = certificate->getSRVNames(); 42 std::vector<std::string> srvNames = certificate->getSRVNames();
41 for (const auto& srvName : srvNames) { 43 for (const auto& srvName : srvNames) {
42 // Only match SRV names that begin with the service; this isn't required per 44 // Only match SRV names that begin with the service; this isn't required per
43 // spec, but we're being purist about this. 45 // spec, but we're being purist about this.
44 if (boost::starts_with(srvName, "_xmpp-client.") && matchesDomain(srvName.substr(std::string("_xmpp-client.").size(), srvName.npos))) { 46 if (boost::starts_with(srvName, prefix) && matchesDomain(srvName.substr(prefix.size(), srvName.npos))) {
45 return true; 47 return true;
46 } 48 }
47 } 49 }