diff options
author | Christian Schneppe <christian@pix-art.de> | 2019-08-31 15:04:51 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2019-08-31 15:04:51 +0200 |
commit | 75923a183536ffdc8adfdae93bf329a8a7da98bb (patch) | |
tree | d93882351de66e9288d11fd545dde760f7c3652a /src/main/java/de/pixart | |
parent | 9acde9e1055ffc02378165f45bbc8cc762a700ed (diff) |
made domain verifier case insensitive.
Diffstat (limited to 'src/main/java/de/pixart')
-rw-r--r-- | src/main/java/de/pixart/messenger/crypto/XmppDomainVerifier.java | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/main/java/de/pixart/messenger/crypto/XmppDomainVerifier.java b/src/main/java/de/pixart/messenger/crypto/XmppDomainVerifier.java index 80a6086aa..fff74104b 100644 --- a/src/main/java/de/pixart/messenger/crypto/XmppDomainVerifier.java +++ b/src/main/java/de/pixart/messenger/crypto/XmppDomainVerifier.java @@ -22,6 +22,7 @@ import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Locale; import javax.net.ssl.SSLSession; @@ -80,14 +81,14 @@ public class XmppDomainVerifier implements DomainHostnameVerifier { break; } Log.d(LOGTAG, "comparing " + needle.substring(i) + " and " + entry.substring(1)); - if (needle.substring(i).equals(entry.substring(1))) { + if (needle.substring(i).equalsIgnoreCase(entry.substring(1))) { Log.d(LOGTAG, "domain " + needle + " matched " + entry); return true; } offset = i + 1; } } else { - if (entry.equals(needle)) { + if (entry.equalsIgnoreCase(needle)) { Log.d(LOGTAG, "domain " + needle + " matched " + entry); return true; } @@ -117,25 +118,25 @@ public class XmppDomainVerifier implements DomainHostnameVerifier { List<String> domains = new ArrayList<>(); if (alternativeNames != null) { for (List<?> san : alternativeNames) { - Integer type = (Integer) san.get(0); + final Integer type = (Integer) san.get(0); if (type == 0) { - Pair<String, String> otherName = parseOtherName((byte[]) san.get(1)); - if (otherName != null) { + final Pair<String, String> otherName = parseOtherName((byte[]) san.get(1)); + if (otherName != null && otherName.first != null && otherName.second != null) { switch (otherName.first) { case SRV_NAME: - srvNames.add(otherName.second); + srvNames.add(otherName.second.toLowerCase(Locale.US)); break; case XMPP_ADDR: - xmppAddrs.add(otherName.second); + xmppAddrs.add(otherName.second.toLowerCase(Locale.US)); break; default: Log.d(LOGTAG, "oid: " + otherName.first + " value: " + otherName.second); } } } else if (type == 2) { - Object value = san.get(1); + final Object value = san.get(1); if (value instanceof String) { - domains.add((String) value); + domains.add(((String) value).toLowerCase(Locale.US)); } } } |