Fixes AMQ-4672 - [JMS Client] Set the SNI field on SSL connections

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1511335 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2013-08-07 14:42:31 +00:00
parent ccde93a238
commit dd286e2381
1 changed files with 11 additions and 0 deletions

View File

@ -21,6 +21,7 @@ import java.io.IOException;
import java.net.URI;
import java.net.UnknownHostException;
import java.security.cert.X509Certificate;
import java.util.HashMap;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession;
@ -29,6 +30,7 @@ import javax.net.ssl.SSLSocketFactory;
import org.apache.activemq.command.ConnectionInfo;
import org.apache.activemq.util.IntrospectionSupport;
import org.apache.activemq.wireformat.WireFormat;
/**
@ -59,6 +61,15 @@ public class SslTransport extends TcpTransport {
super(wireFormat, socketFactory, remoteLocation, localLocation);
if (this.socket != null) {
((SSLSocket)this.socket).setNeedClientAuth(needClientAuth);
// Lets try to configure the SSL SNI field. Handy in case your using
// a single proxy to route to different messaging apps.
// On java 1.7 it seems like it can only be configured via reflection.
// todo: find out if this will work on java 1.8
HashMap props = new HashMap();
props.put("host", remoteLocation.getHost());
IntrospectionSupport.setProperties(this.socket, props);
}
}