LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File openfire-3.6.4-self_signed_certificate.patch of Package openfire (Project server:messaging)

Index: src/java/org/jivesoftware/openfire/net/SSLConfig.java
===================================================================
--- src/java/org/jivesoftware/openfire/net/SSLConfig.java
+++ src/java/org/jivesoftware/openfire/net/SSLConfig.java
@@ -62,7 +62,6 @@
     }
 
     static {
-        String algorithm = JiveGlobals.getProperty("xmpp.socket.ssl.algorithm", "TLS");
         storeType = JiveGlobals.getProperty("xmpp.socket.ssl.storeType", "jks");
 
         // Get the keystore location. The default location is security/keystore
@@ -303,6 +302,12 @@
         try {
             keyStore = KeyStore.getInstance(storeType);
             keyStore.load(null, keypass.toCharArray());
+
+            // Also generate the trustStore if necessary
+            if (s2sTrustStore == null) {
+                s2sTrustStore = KeyStore.getInstance(storeType);
+                s2sTrustStore.load(null, s2sTrustpass.toCharArray());
+            }
         }
         catch (Exception e) {
             Log.error("Unable to initialize keystore: ", e);
@@ -315,9 +320,20 @@
      */
     public static void saveStores() throws IOException {
         try {
+            File keyStoreDirectory = new File(keyStoreLocation).getParentFile();
+            if (!keyStoreDirectory.exists())
+                keyStoreDirectory.mkdirs();
             keyStore.store(new FileOutputStream(keyStoreLocation), keypass.toCharArray());
+
+            File s2sTrustStoreDirectory = new File(s2sTrustStoreLocation).getParentFile();
+            if (!s2sTrustStoreDirectory.exists())
+                s2sTrustStoreDirectory.mkdirs();
             s2sTrustStore.store(new FileOutputStream(s2sTrustStoreLocation), s2sTrustpass.toCharArray());
+
             if (c2sTrustStore != s2sTrustStore) {
+                File c2sTrustStoreDirectory = new File(c2sTrustStoreLocation).getParentFile();
+                if (!c2sTrustStoreDirectory.exists())
+                    c2sTrustStoreDirectory.mkdirs();
                 c2sTrustStore.store(new FileOutputStream(c2sTrustStoreLocation), c2sTrustpass.toCharArray());
             }
         }