mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-23 06:42:05 +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:
parent
7329435c8e
commit
5f9456db0d
1 changed files with 15 additions and 2 deletions
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue