diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/de/blinkt/openvpn/VpnProfile.java | 2 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/core/X509Utils.java | 38 |
2 files changed, 23 insertions, 17 deletions
diff --git a/src/de/blinkt/openvpn/VpnProfile.java b/src/de/blinkt/openvpn/VpnProfile.java index 8b905a84..4c83bf81 100644 --- a/src/de/blinkt/openvpn/VpnProfile.java +++ b/src/de/blinkt/openvpn/VpnProfile.java @@ -574,7 +574,7 @@ public class VpnProfile implements Serializable{ OpenVPN.logMessage(0, "", context.getString(R.string.keychain_nocacert)); for(X509Certificate cert:cachain) { - OpenVPN.logInfo(R.string.cert_from_keystore,cert.getSubjectDN()); + OpenVPN.logInfo(R.string.cert_from_keystore,X509Utils.getCertificateFriendlyName(cert)); } diff --git a/src/de/blinkt/openvpn/core/X509Utils.java b/src/de/blinkt/openvpn/core/X509Utils.java index 0969069f..d07fcaee 100644 --- a/src/de/blinkt/openvpn/core/X509Utils.java +++ b/src/de/blinkt/openvpn/core/X509Utils.java @@ -48,22 +48,8 @@ public class X509Utils { if(!TextUtils.isEmpty(filename)) { try { X509Certificate cert = (X509Certificate) getCertificateFromFile(filename); - - X500Principal principal = (X500Principal) cert.getSubjectDN(); - - String friendlyname = principal.getName(); - System.out.println(friendlyname); - // Really evil hack to decode email address - - String[] parts = friendlyname.split(","); - for (int i=0;i<parts.length;i++){ - String part = parts[i]; - if (part.startsWith("1.2.840.113549.1.9.1=#16")) { - parts[i] = "email=" + ia5decode(part.replace("1.2.840.113549.1.9.1=#16", "")); - } - } - friendlyname = TextUtils.join(",",parts); - return friendlyname; + + return getCertificateFriendlyName(cert); } catch (Exception e) { OpenVPN.logError("Could not read certificate" + e.getLocalizedMessage()); @@ -72,6 +58,26 @@ public class X509Utils { return "Could not read/parse certificate"; } + public static String getCertificateFriendlyName(X509Certificate cert) { + X500Principal principal = (X500Principal) cert.getSubjectDN(); + + String friendlyName = principal.getName(); + System.out.println(friendlyName); + + // Really evil hack to decode email address + // See: http://code.google.com/p/android/issues/detail?id=21531 + + String[] parts = friendlyName.split(","); + for (int i=0;i<parts.length;i++){ + String part = parts[i]; + if (part.startsWith("1.2.840.113549.1.9.1=#16")) { + parts[i] = "email=" + ia5decode(part.replace("1.2.840.113549.1.9.1=#16", "")); + } + } + friendlyName = TextUtils.join(",", parts); + return friendlyName; + } + public static boolean isPrintableChar(char c) { Character.UnicodeBlock block = Character.UnicodeBlock.of( c ); return (!Character.isISOControl(c)) && |