1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-20 17:47:57 +01:00

SMACK-444 Allow 'null' for options in ServerTrustManager

Allow 'null' for TruststorePath and TruststorePassword in ServerTrustManager

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/branches/smack_3_3_2@13766 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Florian Schmaus 2013-10-09 12:31:17 +00:00 committed by flow
parent 9a7bf4a4c3
commit b253203cfb

View file

@ -59,6 +59,7 @@ class ServerTrustManager implements X509TrustManager {
this.server = server;
InputStream in = null;
char[] password = null;
synchronized (stores) {
KeyStoreOptions options = new KeyStoreOptions(configuration.getTruststoreType(),
configuration.getTruststorePath(), configuration.getTruststorePassword());
@ -67,8 +68,18 @@ class ServerTrustManager implements X509TrustManager {
} else {
try {
trustStore = KeyStore.getInstance(options.getType());
in = new FileInputStream(options.getPath());
trustStore.load(in, options.getPassword().toCharArray());
if (options.getPassword() != null) {
password = options.getPassword().toCharArray();
}
if (options.getPath() == null) {
trustStore.load(null, password);
}
else {
in = new FileInputStream(options.getPath());
trustStore.load(in, password);
}
} catch (Exception e) {
trustStore = null;
e.printStackTrace();