1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-07-02 08:16:45 +02:00

Close trust store after loading (SMACK-188).

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7074 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2007-02-12 03:08:40 +00:00 committed by matt
parent 7329435c8e
commit 5f9456db0d

View file

@ -22,6 +22,8 @@ package org.jivesoftware.smack;
import javax.net.ssl.X509TrustManager; import javax.net.ssl.X509TrustManager;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.InputStream;
import java.io.IOException;
import java.security.*; import java.security.*;
import java.security.cert.CertificateException; import java.security.cert.CertificateException;
import java.security.cert.CertificateParsingException; import java.security.cert.CertificateParsingException;
@ -54,16 +56,27 @@ class ServerTrustManager implements X509TrustManager {
this.configuration = configuration; this.configuration = configuration;
this.server = server; this.server = server;
InputStream in = null;
try { try {
trustStore = KeyStore.getInstance(configuration.getTruststoreType()); trustStore = KeyStore.getInstance(configuration.getTruststoreType());
trustStore.load(new FileInputStream(configuration.getTruststorePath()), in = new FileInputStream(configuration.getTruststorePath());
configuration.getTruststorePassword().toCharArray()); trustStore.load(in, configuration.getTruststorePassword().toCharArray());
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
// Disable root CA checking // Disable root CA checking
configuration.setVerifyRootCAEnabled(false); configuration.setVerifyRootCAEnabled(false);
} }
finally {
if (in != null) {
try {
in.close();
}
catch (IOException ioe) {
// Ignore.
}
}
}
} }
public X509Certificate[] getAcceptedIssuers() { public X509Certificate[] getAcceptedIssuers() {