From b274963153efb8620071e958182adc3349dceb4e Mon Sep 17 00:00:00 2001 From: masensio Date: Wed, 5 Mar 2014 12:15:07 +0100 Subject: [PATCH] OC-3163: Check if the certificate is in the app cetificates repository (mKnownServers of NetworkUtils) --- .../owncloud/android/lib/common/network/NetworkUtils.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/com/owncloud/android/lib/common/network/NetworkUtils.java b/src/com/owncloud/android/lib/common/network/NetworkUtils.java index c91faeec..d74d7b99 100644 --- a/src/com/owncloud/android/lib/common/network/NetworkUtils.java +++ b/src/com/owncloud/android/lib/common/network/NetworkUtils.java @@ -172,5 +172,12 @@ public class NetworkUtils { return mConnManager; } + public static boolean isCertInKnownServersStore(Certificate cert, Context context) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException { + + KeyStore knownServers = getKnownServersStore(context); + Log.d(TAG, "Certificate - HashCode: " + cert.hashCode() + " " + + Boolean.toString(knownServers.isCertificateEntry(Integer.toString(cert.hashCode())))); + return knownServers.isCertificateEntry(Integer.toString(cert.hashCode())); + } }