1 18 package org.apache.activemq.transport.tcp; 19 20 import javax.management.remote.JMXPrincipal ; 21 import javax.net.ssl.SSLSocket; 22 import java.io.IOException ; 23 import java.security.cert.X509Certificate ; 24 25 28 public class SslSocketHelper { 29 public static SSLSocket createSSLSocket(String certDistinguishedName, boolean wantAuth, boolean needAuth) throws IOException { 30 JMXPrincipal principal = new JMXPrincipal (certDistinguishedName); 31 X509Certificate cert = new StubX509Certificate(principal); 32 StubSSLSession sslSession = new StubSSLSession(cert); 33 34 StubSSLSocket sslSocket = new StubSSLSocket(sslSession); 35 sslSocket.setWantClientAuth(wantAuth); 36 sslSocket.setNeedClientAuth(needAuth); 37 return sslSocket; 38 } 39 } 40 | Popular Tags |