android: Remove unused hash argument from getTrustedCertificates()
authorTobias Brunner <tobias@strongswan.org>
Fri, 30 May 2014 09:22:19 +0000 (11:22 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 22 Jul 2014 08:41:48 +0000 (10:41 +0200)
src/frontends/android/jni/libandroidbridge/charonservice.c
src/frontends/android/src/org/strongswan/android/logic/CharonVpnService.java

index 707bb3d..32bf28f 100644 (file)
@@ -299,12 +299,12 @@ METHOD(charonservice_t, get_trusted_certificates, linked_list_t*,
 
        method_id = (*env)->GetMethodID(env,
                                                android_charonvpnservice_class,
-                                               "getTrustedCertificates", "(Ljava/lang/String;)[[B");
+                                               "getTrustedCertificates", "()[[B");
        if (!method_id)
        {
                goto failed;
        }
-       jcerts = (*env)->CallObjectMethod(env, this->vpn_service, method_id, NULL);
+       jcerts = (*env)->CallObjectMethod(env, this->vpn_service, method_id);
        if (!jcerts || androidjni_exception_occurred(env))
        {
                goto failed;
index e45a7d9..31172ab 100644 (file)
@@ -419,49 +419,30 @@ public class CharonVpnService extends VpnService implements Runnable
         * Function called via JNI to generate a list of DER encoded CA certificates
         * as byte array.
         *
-        * @param hash optional alias (only hash part), if given matching certificates are returned
         * @return a list of DER encoded CA certificates
         */
-       private byte[][] getTrustedCertificates(String hash)
+       private byte[][] getTrustedCertificates()
        {
                ArrayList<byte[]> certs = new ArrayList<byte[]>();
                TrustedCertificateManager certman = TrustedCertificateManager.getInstance();
                try
                {
-                       if (hash != null)
+                       String alias = this.mCurrentCertificateAlias;
+                       if (alias != null)
                        {
-                               String alias = "user:" + hash + ".0";
                                X509Certificate cert = certman.getCACertificateFromAlias(alias);
                                if (cert == null)
                                {
-                                       alias = "system:" + hash + ".0";
-                                       cert = certman.getCACertificateFromAlias(alias);
-                               }
-                               if (cert == null)
-                               {
                                        return null;
                                }
                                certs.add(cert.getEncoded());
                        }
                        else
                        {
-                               String alias = this.mCurrentCertificateAlias;
-                               if (alias != null)
+                               for (X509Certificate cert : certman.getAllCACertificates().values())
                                {
-                                       X509Certificate cert = certman.getCACertificateFromAlias(alias);
-                                       if (cert == null)
-                                       {
-                                               return null;
-                                       }
                                        certs.add(cert.getEncoded());
                                }
-                               else
-                               {
-                                       for (X509Certificate cert : certman.getAllCACertificates().values())
-                                       {
-                                               certs.add(cert.getEncoded());
-                                       }
-                               }
                        }
                }
                catch (CertificateEncodingException e)