1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-29 23:42:06 +01: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 java.io.FileInputStream;
import java.io.InputStream;
import java.io.IOException;
import java.security.*;
import java.security.cert.CertificateException;
import java.security.cert.CertificateParsingException;
@ -54,16 +56,27 @@ class ServerTrustManager implements X509TrustManager {
this.configuration = configuration;
this.server = server;
InputStream in = null;
try {
trustStore = KeyStore.getInstance(configuration.getTruststoreType());
trustStore.load(new FileInputStream(configuration.getTruststorePath()),
configuration.getTruststorePassword().toCharArray());
in = new FileInputStream(configuration.getTruststorePath());
trustStore.load(in, configuration.getTruststorePassword().toCharArray());
}
catch (Exception e) {
e.printStackTrace();
// Disable root CA checking
configuration.setVerifyRootCAEnabled(false);
}
finally {
if (in != null) {
try {
in.close();
}
catch (IOException ioe) {
// Ignore.
}
}
}
}
public X509Certificate[] getAcceptedIssuers() {