mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-27 00:32:07 +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 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() {
|
||||||
|
|
Loading…
Reference in a new issue