tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni SSL.properties SSLServer.java
Date Mon, 06 Jun 2005 08:15:52 GMT
mturk       2005/06/06 01:15:52

  Added:       jni/examples/org/apache/tomcat/jni SSL.properties
                        SSLServer.java
  Log:
  Add Simple SSL Server example.
  
  Revision  Changes    Path
  1.1                  jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/SSL.properties
  
  Index: SSL.properties
  ===================================================================
  # SSL Server and client properties
  server.port=4443
  server.cert=server.crt
  server.key=server.key
  server.ciphers=ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
  
  
  
  1.1                  jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/SSLServer.java
  
  Index: SSLServer.java
  ===================================================================
  package org.apache.tomcat.jni;
  
  import java.util.Properties;
  
  import java.io.*;
  import java.net.*;
  import java.lang.*;
  
  /** SSL Server server example
   *
   * @author Mladen Turk
   * @version $Revision: 1.1 $, $Date: 2005/06/06 08:15:52 $
   */
  
  public class SSLServer {
  
      public static String serverAddr = null;
      public static int serverPort    = 0;
      public static int serverNmax    = 0;
      public static long serverPool   = 0;
      public static long serverCtx    = 0;
      public static String serverCert = null;
      public static String serverKey  = null;
      public static String serverCiphers  = null;
  
      private static Object threadLock = new Object();
  
      static {
  
          try {
              InputStream is = SSLServer.class.getResourceAsStream
                  ("/org/apache/tomcat/jni/SSL.properties");
              Properties props = new Properties();
              props.load(is);
              is.close();
              serverAddr = props.getProperty("server.ip", "127.0.0.1");
              serverPort = Integer.decode(props.getProperty("server.port", "4443")).intValue();
              serverNmax = Integer.decode(props.getProperty("server.max", "1")).intValue();
              serverCert = props.getProperty("server.cert", "server.pem");
              serverKey  = props.getProperty("server.key", null);
              serverCiphers = props.getProperty("server.ciphers", "ALL");
          }
          catch (Throwable t) {
              ; // Nothing
          }
      }
  
      public SSLServer()
      {
          int i;
          serverPool = Pool.create(0);
          try {
              /* Create SSL Context, one for each Virtual Host */
              serverCtx = SSLContext.make(serverPool, SSL.SSL_PROTOCOL_SSLV2 | SSL.SSL_PROTOCOL_SSLV3,
SSL.SSL_MODE_SERVER);
              /* List the ciphers that the client is permitted to negotiate. */
              SSLContext.setCipherSuite(serverCtx, serverCiphers);
              /* Load Server key and certificate */
              SSLContext.setCertificate(serverCtx, serverCert, serverKey, null, SSL.SSL_AIDX_RSA);
              SSLContext.setVerifyDepth(serverCtx, 10);
              SSLContext.setVerifyClient(serverCtx, SSL.SSL_CVERIFY_REQUIRE);
              
          } catch (Exception e) {
              e.printStackTrace();
          }
  
      }
  
      public static void main(String [] args) {
          try {
              Library.initialize(null);
              SSL.initialize(null);
  
              SSLServer server = new SSLServer();
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message