Author: norman
Date: Tue Nov 23 18:51:16 2010
New Revision: 1038274

URL: http://svn.apache.org/viewvc?rev=1038274&view=rev
Log:
Allow to specify the algorithm for TLS to be able to use secure sockets in non 
SUN JVM's. See JAMS-1139. Thx to Thilo Goetz for the patch!

Modified:
    james/server/trunk/container-spring/src/main/config/examples/smtpserver.xml
    
james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/netty/AbstractConfigurableAsyncServer.java

Modified: 
james/server/trunk/container-spring/src/main/config/examples/smtpserver.xml
URL: 
http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/examples/smtpserver.xml?rev=1038274&r1=1038273&r2=1038274&view=diff
==============================================================================
--- james/server/trunk/container-spring/src/main/config/examples/smtpserver.xml 
(original)
+++ james/server/trunk/container-spring/src/main/config/examples/smtpserver.xml 
Tue Nov 23 18:51:16 2010
@@ -46,6 +46,9 @@
         <keystore>file://conf/keystore</keystore>
         <secret>yoursecret</secret>
         <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+        <!-- The algorithm is optional and only needs to be specified when 
using something other
+        than the Sun JCE provider. -->
+        <algorithm>SunX509</algorithm>
       </tls>
       
       <handler>

Modified: 
james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/netty/AbstractConfigurableAsyncServer.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/netty/AbstractConfigurableAsyncServer.java?rev=1038274&r1=1038273&r2=1038274&view=diff
==============================================================================
--- 
james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/netty/AbstractConfigurableAsyncServer.java
 (original)
+++ 
james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/netty/AbstractConfigurableAsyncServer.java
 Tue Nov 23 18:51:16 2010
@@ -73,6 +73,13 @@ public abstract class AbstractConfigurab
      */
     public static final String HELLO_NAME = "helloName";
     
+    // By default, use the Sun X509 algorithm that comes with the Sun JCE 
provider for SSL 
+    // certificates
+    private static final String defaultX509algorithm = "SunX509";
+    
+    // The X.509 certificate algorithm
+    private String x509Algorithm = defaultX509algorithm;
+    
     private FileSystem fileSystem;
 
     private Log logger;
@@ -236,6 +243,7 @@ public abstract class AbstractConfigurab
                 throw new ConfigurationException("keystore needs to get 
configured");
             }
             secret = config.getString("tls.secret","");
+            x509Algorithm = config.getString("tls.algorithm", 
defaultX509algorithm);
         }
              
         doConfigure(config);
@@ -387,12 +395,11 @@ public abstract class AbstractConfigurab
     
     private void buildSSLContext() throws Exception {
         if (useStartTLS || useSSL) {
-            String algorithm = "SunX509";
             KeyStore ks = KeyStore.getInstance("JKS");
             ks.load(new FileInputStream(fileSystem.getFile(keystore)), 
secret.toCharArray());
 
             // Set up key manager factory to use our key store
-            KeyManagerFactory kmf = KeyManagerFactory.getInstance(algorithm);
+            KeyManagerFactory kmf = 
KeyManagerFactory.getInstance(x509Algorithm);
             kmf.init(ks, secret.toCharArray());
 
             // Initialize the SSLContext to work with our key managers.



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to