Repository: camel Updated Branches: refs/heads/camel-2.15.x 360c6c26a -> fa726cd0e
CAMEL-8707 Fixed the issue of camel-smpps doesn't work over proxy with thanks to Gururaja Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/4576e78a Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4576e78a Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4576e78a Branch: refs/heads/camel-2.15.x Commit: 4576e78a344a8e9402545444629a9adceb62e90d Parents: 360c6c2 Author: Willem Jiang <willem.ji...@gmail.com> Authored: Tue Apr 28 14:23:24 2015 +0800 Committer: Willem Jiang <willem.ji...@gmail.com> Committed: Tue Apr 28 21:59:55 2015 +0800 ---------------------------------------------------------------------- .../component/smpp/SmppConnectionFactory.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/4576e78a/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppConnectionFactory.java ---------------------------------------------------------------------- diff --git a/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppConnectionFactory.java b/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppConnectionFactory.java index 1f9d932..ff8a57b 100644 --- a/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppConnectionFactory.java +++ b/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppConnectionFactory.java @@ -55,6 +55,7 @@ import java.io.OutputStream; import java.net.Socket; import javax.net.SocketFactory; +import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; import org.apache.camel.RuntimeCamelException; @@ -84,15 +85,25 @@ public final class SmppConnectionFactory implements ConnectionFactory { try { Socket socket; SocketFactory socketFactory; - socketFactory = config.getUsingSSL() ? SSLSocketFactory.getDefault() : SocketFactory.getDefault(); + socketFactory = config.getUsingSSL() && config.getHttpProxyHost() == null ? SSLSocketFactory + .getDefault() : SocketFactory.getDefault(); if (config.getHttpProxyHost() != null) { + // setup the proxy tunnel socket = socketFactory.createSocket(config.getHttpProxyHost(), config.getHttpProxyPort()); connectProxy(host, port, socket); } else { socket = socketFactory.createSocket(host, port); } - return new SocketConnection(socket); + if (config.getUsingSSL() && config.getHttpProxyHost() != null) { + // Init the SSL socket which is based on the proxy socket + SSLSocketFactory sslSocketFactory = (SSLSocketFactory)SSLSocketFactory.getDefault(); + SSLSocket sslSocket = (SSLSocket)sslSocketFactory.createSocket(socket, host, port, true); + sslSocket.startHandshake(); + socket = sslSocket; + } + + return new SocketConnection(socket); } catch (Exception e) { throw new IOException(e.getMessage()); } @@ -167,4 +178,4 @@ public final class SmppConnectionFactory implements ConnectionFactory { } } } -} \ No newline at end of file +}