aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-rw-r--r--src/main/java/de/pixart/messenger/utils/CryptoHelper.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/main/java/de/pixart/messenger/utils/CryptoHelper.java b/src/main/java/de/pixart/messenger/utils/CryptoHelper.java
index da34200bf..f9abe8c90 100644
--- a/src/main/java/de/pixart/messenger/utils/CryptoHelper.java
+++ b/src/main/java/de/pixart/messenger/utils/CryptoHelper.java
@@ -160,15 +160,23 @@ public final class CryptoHelper {
}
}
X500Name x500name = new JcaX509CertificateHolder(certificate).getSubject();
- if (emails.size() == 0) {
+ if (emails.size() == 0 && x500name.getRDNs(BCStyle.EmailAddress).length > 0) {
emails.add(IETFUtils.valueToString(x500name.getRDNs(BCStyle.EmailAddress)[0].getFirst().getValue()));
}
- String name = IETFUtils.valueToString(x500name.getRDNs(BCStyle.CN)[0].getFirst().getValue());
+ String name = x500name.getRDNs(BCStyle.CN).length > 0 ? IETFUtils.valueToString(x500name.getRDNs(BCStyle.CN)[0].getFirst().getValue()) : null;
if (emails.size() >= 1) {
return new Pair<>(Jid.fromString(emails.get(0)), name);
- } else {
- return null;
+ } else if (name != null) {
+ try {
+ Jid jid = Jid.fromString(name);
+ if (jid.isBareJid() && !jid.isDomainJid()) {
+ return new Pair<>(jid, null);
+ }
+ } catch (InvalidJidException e) {
+ return null;
+ }
}
+ return null;
}
public static Bundle extractCertificateInformation(X509Certificate certificate) {