Commit 42903a5e authored by guus's avatar guus

OF-533: Protocol obtained from SSLContext should be configurable.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13001 b35dd754-fafc-0310-a699-88a17e54d16e
parent 41b6112f
...@@ -37,6 +37,7 @@ import javax.net.ssl.SSLEngineResult.HandshakeStatus; ...@@ -37,6 +37,7 @@ import javax.net.ssl.SSLEngineResult.HandshakeStatus;
import javax.net.ssl.SSLEngineResult.Status; import javax.net.ssl.SSLEngineResult.Status;
import org.jivesoftware.openfire.Connection; import org.jivesoftware.openfire.Connection;
import org.jivesoftware.util.JiveGlobals;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -68,8 +69,6 @@ public class TLSWrapper { ...@@ -68,8 +69,6 @@ public class TLSWrapper {
*/ */
private static boolean debug = false; private static boolean debug = false;
private static final String PROTOCOL = "TLS";
private SSLEngine tlsEngine; private SSLEngine tlsEngine;
private SSLEngineResult tlsEngineResult; private SSLEngineResult tlsEngineResult;
...@@ -83,6 +82,8 @@ public class TLSWrapper { ...@@ -83,6 +82,8 @@ public class TLSWrapper {
System.setProperty("javax.net.debug", "all"); System.setProperty("javax.net.debug", "all");
} }
String algorithm = JiveGlobals.getProperty("xmpp.socket.ssl.algorithm", "TLS");
// Create/initialize the SSLContext with key material // Create/initialize the SSLContext with key material
try { try {
// First initialize the key and trust material. // First initialize the key and trust material.
...@@ -108,7 +109,7 @@ public class TLSWrapper { ...@@ -108,7 +109,7 @@ public class TLSWrapper {
} }
} }
SSLContext tlsContext = SSLContext.getInstance(PROTOCOL); SSLContext tlsContext = SSLContext.getInstance(algorithm);
tlsContext.init(km, tm, null); tlsContext.init(km, tm, null);
...@@ -128,7 +129,7 @@ public class TLSWrapper { ...@@ -128,7 +129,7 @@ public class TLSWrapper {
} catch (KeyManagementException e) { } catch (KeyManagementException e) {
Log.error("TLSHandler startup problem.\n" + " SSLContext initialisation failed.", e); Log.error("TLSHandler startup problem.\n" + " SSLContext initialisation failed.", e);
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
Log.error("TLSHandler startup problem.\n" + " The " + PROTOCOL + " does not exist", e); Log.error("TLSHandler startup problem.\n" + " The " + algorithm + " does not exist", e);
} catch (IOException e) { } catch (IOException e) {
Log.error("TLSHandler startup problem.\n" Log.error("TLSHandler startup problem.\n"
+ " the KeyStore or TrustStore does not exist", e); + " the KeyStore or TrustStore does not exist", e);
......
...@@ -346,7 +346,8 @@ public class NIOConnection implements Connection { ...@@ -346,7 +346,8 @@ public class NIOConnection implements Connection {
} }
} }
SSLContext tlsContext = SSLContext.getInstance("TLS"); String algorithm = JiveGlobals.getProperty("xmpp.socket.ssl.algorithm", "TLS");
SSLContext tlsContext = SSLContext.getInstance(algorithm);
tlsContext.init(km, tm, null); tlsContext.init(km, tm, null);
......
...@@ -409,10 +409,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana ...@@ -409,10 +409,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
// Start clients SSL unless it's been disabled. // Start clients SSL unless it's been disabled.
if (isClientSSLListenerEnabled()) { if (isClientSSLListenerEnabled()) {
int port = getClientSSLListenerPort(); int port = getClientSSLListenerPort();
String algorithm = JiveGlobals.getProperty("xmpp.socket.ssl.algorithm"); String algorithm = JiveGlobals.getProperty("xmpp.socket.ssl.algorithm", "TLS");
if ("".equals(algorithm) || algorithm == null) {
algorithm = "TLS";
}
try { try {
// Create SocketAcceptor with correct number of processors // Create SocketAcceptor with correct number of processors
sslSocketAcceptor = buildSocketAcceptor(); sslSocketAcceptor = buildSocketAcceptor();
......
...@@ -54,7 +54,8 @@ public class SimpleSSLSocketFactory extends SSLSocketFactory { ...@@ -54,7 +54,8 @@ public class SimpleSSLSocketFactory extends SSLSocketFactory {
public SimpleSSLSocketFactory() { public SimpleSSLSocketFactory() {
try { try {
SSLContext sslcontent = SSLContext.getInstance("TLS"); String algorithm = JiveGlobals.getProperty("xmpp.socket.ssl.algorithm", "TLS");
SSLContext sslcontent = SSLContext.getInstance(algorithm);
sslcontent.init(null, // KeyManager not required sslcontent.init(null, // KeyManager not required
new TrustManager[] { new DummyTrustManager() }, new TrustManager[] { new DummyTrustManager() },
new java.security.SecureRandom()); new java.security.SecureRandom());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment