From b253203cfbc233665392585b33de83e55273cccf Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 9 Oct 2013 12:31:17 +0000 Subject: [PATCH] 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 --- .../jivesoftware/smack/ServerTrustManager.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/source/org/jivesoftware/smack/ServerTrustManager.java b/source/org/jivesoftware/smack/ServerTrustManager.java index afc4e23f9..19faed90c 100644 --- a/source/org/jivesoftware/smack/ServerTrustManager.java +++ b/source/org/jivesoftware/smack/ServerTrustManager.java @@ -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();