Commit e595dd6f authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

[JM-1394] More improvements from Corey Wright.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@10546 b35dd754-fafc-0310-a699-88a17e54d16e
parent cec7c04c
...@@ -460,7 +460,12 @@ public class SASLAuthentication { ...@@ -460,7 +460,12 @@ public class SASLAuthentication {
for (Certificate certificate : connection.getPeerCertificates()) { for (Certificate certificate : connection.getPeerCertificates()) {
for (String identity : CertificateManager.getPeerIdentities((X509Certificate) certificate)) { for (String identity : CertificateManager.getPeerIdentities((X509Certificate) certificate)) {
if (identity.equals(hostname) || identity.equals("*." + hostname)) { // Verify that either the identity is the same as the hostname, or for wildcarded
// identities that the hostname ends with .domainspecified or -is- domainspecified.
if ((identity.startsWith("*.")
&& (hostname.endsWith(identity.replace("*.", "."))
|| hostname.equals(identity.replace("*.", ""))))
|| hostname.equals(identity)) {
authenticationSuccessful(session, hostname, null); authenticationSuccessful(session, hostname, null);
return Status.authenticated; return Status.authenticated;
} }
......
...@@ -140,23 +140,15 @@ public class ServerTrustManager implements X509TrustManager { ...@@ -140,23 +140,15 @@ public class ServerTrustManager implements X509TrustManager {
// a wildcard. // a wildcard.
Boolean found = false; Boolean found = false;
for (String identity : peerIdentities) { for (String identity : peerIdentities) {
if (identity.startsWith("*.")) { // Verify that either the identity is the same as the hostname, or for wildcarded
// strip off asterisks, but keep leading dot // identities that the hostname ends with .domainspecified or -is- domainspecified.
// to insure endsWith() only matches a subdomain if ((identity.startsWith("*.")
// of the intended domain && (server.endsWith(identity.replace("*.", "."))
identity = identity.replace("*.", "."); || server.equals(identity.replace("*.", ""))))
if (server.endsWith(identity)) { || server.equals(identity)) {
found = true; found = true;
break; break;
}
}
else {
if (server.equals(identity)) {
found = true;
break;
}
} }
} }
if (!found) { if (!found) {
......
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