Commit c83fde0e authored by guus's avatar guus

Provisional fix for certificates that have tagged objects instead of plain...

Provisional fix for certificates that have tagged objects instead of plain strings in their subject alternative names section.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@12975 b35dd754-fafc-0310-a699-88a17e54d16e
parent 26a0bb62
...@@ -57,6 +57,8 @@ import java.util.regex.Pattern; ...@@ -57,6 +57,8 @@ import java.util.regex.Pattern;
import org.bouncycastle.asn1.ASN1Encodable; import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1InputStream; import org.bouncycastle.asn1.ASN1InputStream;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.DEREncodable;
import org.bouncycastle.asn1.DERObjectIdentifier; import org.bouncycastle.asn1.DERObjectIdentifier;
import org.bouncycastle.asn1.DEROutputStream; import org.bouncycastle.asn1.DEROutputStream;
import org.bouncycastle.asn1.DERSequence; import org.bouncycastle.asn1.DERSequence;
...@@ -253,16 +255,27 @@ public class CertificateManager { ...@@ -253,16 +255,27 @@ public class CertificateManager {
// Check the object identifier // Check the object identifier
DERObjectIdentifier objectId = (DERObjectIdentifier) otherNameSeq.getObjectAt(0); DERObjectIdentifier objectId = (DERObjectIdentifier) otherNameSeq.getObjectAt(0);
Log.debug("Parsing otherName for subject alternative names: " + objectId.toString() );
if ( !OTHERNAME_XMPP_OID.equals(objectId.getId())) { if ( !OTHERNAME_XMPP_OID.equals(objectId.getId())) {
// Not a XMPP otherName // Not a XMPP otherName
Log.debug("CertificateManager: Ignoring non-XMPP otherName, " + objectId.getId()); Log.debug("Ignoring non-XMPP otherName, " + objectId.getId());
continue; continue;
} }
// Get identity string // Get identity string
try { try {
DERUTF8String derStr = DERUTF8String.getInstance(otherNameSeq.getObjectAt(1)); final String identity;
String identity = derStr.getString(); DEREncodable o = otherNameSeq.getObjectAt(1);
if (o instanceof DERTaggedObject) {
ASN1TaggedObject ato = DERTaggedObject.getInstance(o);
Log.debug("... processing DERTaggedObject: " + ato.toString());
// TODO: there's bound to be a better way...
identity = ato.toString().substring(ato.toString().lastIndexOf(']')+1).trim();
} else {
DERUTF8String derStr = DERUTF8String.getInstance(o);
identity = derStr.getString();
}
if (identity != null && identity.length() > 0) { if (identity != null && identity.length() > 0) {
// Add the decoded server name to the list of identities // Add the decoded server name to the list of identities
identities.add(identity); identities.add(identity);
...@@ -279,14 +292,14 @@ public class CertificateManager { ...@@ -279,14 +292,14 @@ public class CertificateManager {
// Ignore // Ignore
} }
catch (Exception e) { catch (Exception e) {
Log.error("CertificateManager: Error decoding subjectAltName", e); Log.error("Error decoding subjectAltName", e);
} }
} }
// Other types are not applicable for XMPP, so silently ignore them // Other types are not applicable for XMPP, so silently ignore them
} }
} }
catch (CertificateParsingException e) { catch (CertificateParsingException e) {
Log.error("CertificateManager: Error parsing SubjectAltName in certificate: " + certificate.getSubjectDN(), e); Log.error("Error parsing SubjectAltName in certificate: " + certificate.getSubjectDN(), e);
} }
return identities; return identities;
} }
......
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