title: SSL Sockets in Java
body: <p>I want to secure comunication in my application using SSL. I am using <em>org.apache.commons.ssl</em> and OpenSSL. I have created key and crt like this (those are self signed for now):</p>
  
  <pre><code>openssl req -new -x509 -nodes -out szrr.crt -keyout szrr.key
  openssl rsa -des3 -in szrr.key -out szrr.key.new
  del szrr.key
  move szrr.key.new szrr.key
  </code></pre>
  
  <p>So i have now key and cert which i use this way:</p>
  
  <pre><code>KeyMaterial km = new KeyMaterial(certChain, key, password);
  SSLServer sslServer = new SSLServer();
  sslServer.setKeyMaterial(km);
  sslServer.addTrustMaterial(TrustMaterial.TRUST_ALL);
  sslServerSocket = (SSLServerSocket) sslServer
                      .createServerSocket(serverPort);
  </code></pre>
  
  <p>certChain, key are paths to crt and key, password is just password :)</p>
  
  <p>Now what else do I have to do to create SSLClient similar way?</p>