android: Remove unused hash argument from getTrustedCertificates()

This commit is contained in:
Tobias Brunner
2014-07-22 10:41:48 +02:00
parent b9fd95f476
commit 9d994ba5ea
2 changed files with 6 additions and 25 deletions
@@ -299,12 +299,12 @@ METHOD(charonservice_t, get_trusted_certificates, linked_list_t*,
method_id = (*env)->GetMethodID(env, method_id = (*env)->GetMethodID(env,
android_charonvpnservice_class, android_charonvpnservice_class,
"getTrustedCertificates", "(Ljava/lang/String;)[[B"); "getTrustedCertificates", "()[[B");
if (!method_id) if (!method_id)
{ {
goto failed; 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)) if (!jcerts || androidjni_exception_occurred(env))
{ {
goto failed; goto failed;
@@ -419,25 +419,19 @@ public class CharonVpnService extends VpnService implements Runnable
* Function called via JNI to generate a list of DER encoded CA certificates * Function called via JNI to generate a list of DER encoded CA certificates
* as byte array. * as byte array.
* *
* @param hash optional alias (only hash part), if given matching certificates are returned
* @return a list of DER encoded CA certificates * @return a list of DER encoded CA certificates
*/ */
private byte[][] getTrustedCertificates(String hash) private byte[][] getTrustedCertificates()
{ {
ArrayList<byte[]> certs = new ArrayList<byte[]>(); ArrayList<byte[]> certs = new ArrayList<byte[]>();
TrustedCertificateManager certman = TrustedCertificateManager.getInstance(); TrustedCertificateManager certman = TrustedCertificateManager.getInstance();
try try
{ {
if (hash != null) String alias = this.mCurrentCertificateAlias;
if (alias != null)
{ {
String alias = "user:" + hash + ".0";
X509Certificate cert = certman.getCACertificateFromAlias(alias); X509Certificate cert = certman.getCACertificateFromAlias(alias);
if (cert == null) if (cert == null)
{
alias = "system:" + hash + ".0";
cert = certman.getCACertificateFromAlias(alias);
}
if (cert == null)
{ {
return null; return null;
} }
@@ -445,23 +439,10 @@ public class CharonVpnService extends VpnService implements Runnable
} }
else else
{ {
String alias = this.mCurrentCertificateAlias; for (X509Certificate cert : certman.getAllCACertificates().values())
if (alias != null)
{ {
X509Certificate cert = certman.getCACertificateFromAlias(alias);
if (cert == null)
{
return null;
}
certs.add(cert.getEncoded()); certs.add(cert.getEncoded());
} }
else
{
for (X509Certificate cert : certman.getAllCACertificates().values())
{
certs.add(cert.getEncoded());
}
}
} }
} }
catch (CertificateEncodingException e) catch (CertificateEncodingException e)