mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-16 09:12:06 +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:
parent
9a7bf4a4c3
commit
b253203cfb
1 changed files with 13 additions and 2 deletions
|
@ -59,6 +59,7 @@ class ServerTrustManager implements X509TrustManager {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
|
|
||||||
InputStream in = null;
|
InputStream in = null;
|
||||||
|
char[] password = null;
|
||||||
synchronized (stores) {
|
synchronized (stores) {
|
||||||
KeyStoreOptions options = new KeyStoreOptions(configuration.getTruststoreType(),
|
KeyStoreOptions options = new KeyStoreOptions(configuration.getTruststoreType(),
|
||||||
configuration.getTruststorePath(), configuration.getTruststorePassword());
|
configuration.getTruststorePath(), configuration.getTruststorePassword());
|
||||||
|
@ -67,8 +68,18 @@ class ServerTrustManager implements X509TrustManager {
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
trustStore = KeyStore.getInstance(options.getType());
|
trustStore = KeyStore.getInstance(options.getType());
|
||||||
|
if (options.getPassword() != null) {
|
||||||
|
password = options.getPassword().toCharArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.getPath() == null) {
|
||||||
|
trustStore.load(null, password);
|
||||||
|
}
|
||||||
|
else {
|
||||||
in = new FileInputStream(options.getPath());
|
in = new FileInputStream(options.getPath());
|
||||||
trustStore.load(in, options.getPassword().toCharArray());
|
trustStore.load(in, password);
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
trustStore = null;
|
trustStore = null;
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
Loading…
Reference in a new issue