diff options
author | Arne Schwabe <arne@rfc2549.org> | 2013-06-07 00:15:00 +0200 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2013-06-07 00:15:00 +0200 |
commit | d596b51b383321531654726a5124a88cdcd9cd79 (patch) | |
tree | 78f79ac47fd113bc455c0b63b09111425b1cff4a /src/de/blinkt | |
parent | 4ea518c9572a7c92362086332fe987ae31e6536e (diff) |
Also use friendly names when printing keystore certificate
--HG--
extra : rebase_source : 4168ea0e489768c5fa2f5b54619d96e880e380c6
Diffstat (limited to 'src/de/blinkt')
-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)) && |