Repository: camel
Updated Branches:
  refs/heads/camel-2.14.x 77e7aa258 -> 6bfcd9bf2


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/4ce91e08
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4ce91e08
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4ce91e08

Branch: refs/heads/camel-2.14.x
Commit: 4ce91e08c4dce8d5a29cfbdb0d0d7f0b5be7e88c
Parents: 77e7aa2
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 22:01:45 2015 +0800

----------------------------------------------------------------------
 .../component/smpp/SmppConnectionFactory.java      | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4ce91e08/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
+}

Reply via email to