Re: [Simpleweb-Support] SSL Client Authentication
Brought to you by:
niallg
From: Niall G. <gal...@ya...> - 2013-06-06 07:25:31
|
Try this public class MyServer implements org.simpleframework.transport.Server { private Server delegateServer; public MyServer(Server delegateServer){ this.delegateServer = delegateServer; } public void process(Socket socket){ socket.getSSLEngine().setNeedClientAuth(true); delegateServer.process(socket); }} --- On Tue, 4/6/13, Mike Deck <mik...@gm...> wrote: From: Mike Deck <mik...@gm...> Subject: [Simpleweb-Support] SSL Client Authentication To: sim...@li... Received: Tuesday, 4 June, 2013, 6:33 PM Is there a good way to configure Simple to require a valid client certificate when using an SSL connection? I have the following bare-bones server and I would like to know what the correct process is to enable client certificate authentication on it. Any help would be much appreciated. Thanks,Mike -------Begin Example----- public static void main(String[] args) throws Exception { Container container = createContainer(); Server server = new ContainerServer(container); Connection connection = new SocketConnection(server); SocketAddress address = new InetSocketAddress(8443); KeyManagerFactory km = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); KeyStore serverKeystore = KeyStore.getInstance(KeyStore.getDefaultType()); try(InputStream keystoreFile = new FileInputStream(SERVER_KEYSTORE_PATH)) { serverKeystore.load(keystoreFile, "asdfgh".toCharArray()); } km.init(serverKeystore, "asdf".toCharArray()); TrustManagerFactory tm = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); KeyStore caKeystore = KeyStore.getInstance(KeyStore.getDefaultType()); try(InputStream caCertFile = new FileInputStream(CA_CERT_PATH)) { caKeystore.load(caCertFile, "asdfgh".toCharArray()); } tm.init(caKeystore); SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(km.getKeyManagers(), tm.getTrustManagers(), null); sslContext.getDefaultSSLParameters().setNeedClientAuth(true); connection.connect(address, sslContext); } -----Inline Attachment Follows----- ------------------------------------------------------------------------------ How ServiceNow helps IT people transform IT departments: 1. A cloud service to automate IT design, transition and operations 2. Dashboards that offer high-level views of enterprise services 3. A single system of record for all IT processes http://p.sf.net/sfu/servicenow-d2d-j -----Inline Attachment Follows----- _______________________________________________ Simpleweb-Support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simpleweb-support |