You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2018/01/28 09:30:28 UTC

[GitHub] sijie closed pull request #965: Issue 933: Add support for PEM Key file formats

sijie closed pull request #965: Issue 933: Add support for PEM Key file formats
URL: https://github.com/apache/bookkeeper/pull/965
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/bookkeeper-server/pom.xml b/bookkeeper-server/pom.xml
index bbf218fab..7b583d370 100644
--- a/bookkeeper-server/pom.xml
+++ b/bookkeeper-server/pom.xml
@@ -284,13 +284,16 @@
             <exclude>**/.project</exclude>
             <exclude>**/.checkstyle</exclude>
             <exclude>**/.settings/*</exclude>
-            <exclude>certs/keyStoreClientPassword.txt</exclude>
-            <exclude>certs/keyStoreServerPassword.txt</exclude>
-            <exclude>certs/trustStorePassword.txt</exclude>
-            <exclude>src/test/resources/cacerts</exclude>
+            <exclude>src/test/resources/server-key.pem</exclude>
+            <exclude>src/test/resources/server-key.p12</exclude>
+            <exclude>src/test/resources/server-key.jks</exclude>
+            <exclude>src/test/resources/server-cert.pem</exclude>
+            <exclude>src/test/resources/client-key.pem</exclude>
+            <exclude>src/test/resources/client-key.p12</exclude>
+            <exclude>src/test/resources/client-key.jks</exclude>
+            <exclude>src/test/resources/client-cert.pem</exclude>
             <exclude>src/test/resources/keyStoreClientPassword.txt</exclude>
             <exclude>src/test/resources/keyStoreServerPassword.txt</exclude>
-            <exclude>src/test/resources/trustStorePassword.txt</exclude>
           </excludes>
         </configuration>
       </plugin>
@@ -478,5 +481,30 @@
         </dependency>
       </dependencies>
     </profile>
+    <profile>
+      <id>tls-certs</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.codehaus.mojo</groupId>
+            <artifactId>exec-maven-plugin</artifactId>
+            <version>1.6.0</version>
+            <executions>
+              <execution>
+                <id>Generate Self-Signed Certificates</id>
+                <phase>generate-test-resources</phase>
+                <goals>
+                  <goal>exec</goal>
+                </goals>
+                <configuration>
+                  <workingDirectory>${basedir}/src/test/resources</workingDirectory>
+                  <executable>${basedir}/src/test/resources/generateKeysAndCerts.sh</executable>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
   </profiles>
 </project>
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/AbstractConfiguration.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/AbstractConfiguration.java
index f963f8b63..ef8e90880 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/AbstractConfiguration.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/AbstractConfiguration.java
@@ -100,6 +100,17 @@
     */
     protected static final String TLS_ENABLED_PROTOCOLS = "tlsEnabledProtocols";
 
+    /**
+     * TLS KeyStore, TrustStore, Password files and Certificate Paths.
+     */
+    protected static final String TLS_KEYSTORE_TYPE = "tlsKeyStoreType";
+    protected static final String TLS_KEYSTORE = "tlsKeyStore";
+    protected static final String TLS_KEYSTORE_PASSWORD_PATH = "tlsKeyStorePasswordPath";
+    protected static final String TLS_TRUSTSTORE_TYPE = "tlsTrustStoreType";
+    protected static final String TLS_TRUSTSTORE = "tlsTrustStore";
+    protected static final String TLS_TRUSTSTORE_PASSWORD_PATH = "tlsTrustStorePasswordPath";
+    protected static final String TLS_CERTIFICATE_PATH = "tlsCertificatePath";
+
     //Netty configuration
     protected static final String NETTY_MAX_FRAME_SIZE = "nettyMaxFrameSizeBytes";
     protected static final int DEFAULT_NETTY_MAX_FRAME_SIZE = 5 * 1024 * 1024; // 5MB
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ClientConfiguration.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ClientConfiguration.java
index 4d9c77478..424ae34f1 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ClientConfiguration.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ClientConfiguration.java
@@ -51,6 +51,43 @@
     // Passwd
     protected static final String PASSWD = "passwd";
 
+    // Client TLS (@deprecated since 4.7.0)
+    /**
+     * @deprecated Use {@link #TLS_KEYSTORE_TYPE}
+     */
+    @Deprecated
+    protected static final String CLIENT_TLS_KEYSTORE_TYPE = "clientKeyStoreType";
+
+    /**
+     * @deprecated Use {@link #TLS_KEYSTORE}
+     */
+    @Deprecated
+    protected static final String CLIENT_TLS_KEYSTORE = "clientKeyStore";
+
+    /**
+     * @deprecated Use {@link #TLS_KEYSTORE_PASSWORD_PATH}
+     */
+    @Deprecated
+    protected static final String CLIENT_TLS_KEYSTORE_PASSWORD_PATH = "clientKeyStorePasswordPath";
+
+    /**
+     * @deprecated Use {@link #TLS_TRUSTSTORE_TYPE}
+     */
+    @Deprecated
+    protected static final String CLIENT_TLS_TRUSTSTORE_TYPE = "clientTrustStoreType";
+
+    /**
+     * @deprecated Use {@link #TLS_TRUSTSTORE}
+     */
+    @Deprecated
+    protected static final String CLIENT_TLS_TRUSTSTORE = "clientTrustStore";
+
+    /**
+     * @deprecated Use {@link #TLS_TRUSTSTORE_PASSWORD_PATH}
+     */
+    @Deprecated
+    protected static final String CLIENT_TLS_TRUSTSTORE_PASSWORD_PATH = "clientTrustStorePasswordPath";
+
     // NIO Parameters
     protected static final String CLIENT_TCP_NODELAY = "clientTcpNoDelay";
     protected static final String CLIENT_SOCK_KEEPALIVE = "clientSockKeepalive";
@@ -145,14 +182,6 @@
     // Client auth provider factory class name. It must be configured on Bookies to for the Auditor
     protected static final String CLIENT_AUTH_PROVIDER_FACTORY_CLASS = "clientAuthProviderFactoryClass";
 
-    // Client TLS
-    protected static final String TLS_KEYSTORE_TYPE = "clientKeyStoreType";
-    protected static final String TLS_KEYSTORE = "clientKeyStore";
-    protected static final String TLS_KEYSTORE_PASSWORD_PATH = "clientKeyStorePasswordPath";
-    protected static final String TLS_TRUSTSTORE_TYPE = "clientTrustStoreType";
-    protected static final String TLS_TRUSTSTORE = "clientTrustStore";
-    protected static final String TLS_TRUSTSTORE_PASSWORD_PATH = "clientTrustStorePasswordPath";
-
     // Registration Client
     protected static final String REGISTRATION_CLIENT_CLASS = "registrationClientClass";
 
@@ -1419,7 +1448,7 @@ public String getClientRole() {
      * @return
      */
     public String getTLSKeyStoreType() {
-        return getString(TLS_KEYSTORE_TYPE, "JKS");
+        return getString(CLIENT_TLS_KEYSTORE_TYPE, getString(TLS_KEYSTORE_TYPE, "JKS"));
     }
 
 
@@ -1439,7 +1468,7 @@ public ClientConfiguration setTLSKeyStoreType(String arg) {
      * @return
      */
     public String getTLSKeyStore() {
-        return getString(TLS_KEYSTORE, null);
+        return getString(CLIENT_TLS_KEYSTORE, getString(TLS_KEYSTORE, null));
     }
 
     /**
@@ -1458,7 +1487,7 @@ public ClientConfiguration setTLSKeyStore(String arg) {
      * @return
      */
     public String getTLSKeyStorePasswordPath() {
-        return getString(TLS_KEYSTORE_PASSWORD_PATH, null);
+        return getString(CLIENT_TLS_KEYSTORE_PASSWORD_PATH, getString(TLS_KEYSTORE_PASSWORD_PATH, null));
     }
 
     /**
@@ -1477,7 +1506,7 @@ public ClientConfiguration setTLSKeyStorePasswordPath(String arg) {
      * @return
      */
     public String getTLSTrustStoreType() {
-        return getString(TLS_TRUSTSTORE_TYPE, "JKS");
+        return getString(CLIENT_TLS_TRUSTSTORE_TYPE, getString(TLS_TRUSTSTORE_TYPE, "JKS"));
     }
 
     /**
@@ -1496,7 +1525,7 @@ public ClientConfiguration setTLSTrustStoreType(String arg) {
      * @return
      */
     public String getTLSTrustStore() {
-        return getString(TLS_TRUSTSTORE, null);
+        return getString(CLIENT_TLS_TRUSTSTORE, getString(TLS_TRUSTSTORE, null));
     }
 
     /**
@@ -1516,7 +1545,7 @@ public ClientConfiguration setTLSTrustStore(String arg) {
      * @return
      */
     public String getTLSTrustStorePasswordPath() {
-        return getString(TLS_TRUSTSTORE_PASSWORD_PATH, null);
+        return getString(CLIENT_TLS_TRUSTSTORE_PASSWORD_PATH, getString(TLS_TRUSTSTORE_PASSWORD_PATH, null));
     }
 
     /**
@@ -1529,6 +1558,25 @@ public ClientConfiguration setTLSTrustStorePasswordPath(String arg) {
         return this;
     }
 
+    /**
+     * Get the path to file containing TLS Certificate.
+     *
+     * @return
+     */
+    public String getTLSCertificatePath() {
+        return getString(TLS_CERTIFICATE_PATH, null);
+    }
+
+    /**
+     * Set the path to file containing TLS Certificate.
+     *
+     * @return
+     */
+    public ClientConfiguration setTLSCertificatePath(String arg) {
+        setProperty(TLS_CERTIFICATE_PATH, arg);
+        return this;
+    }
+
     /**
      * Whether to delay ensemble change or not?
      *
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ServerConfiguration.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ServerConfiguration.java
index d6e4d5f37..3a7c763de 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ServerConfiguration.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ServerConfiguration.java
@@ -168,14 +168,6 @@
     protected static final String HTTP_SERVER_ENABLED = "httpServerEnabled";
     protected static final String HTTP_SERVER_PORT = "httpServerPort";
 
-    // TLS parameters
-    protected static final String TLS_KEYSTORE_TYPE = "tlsKeyStoreType";
-    protected static final String TLS_KEYSTORE = "tlsKeyStore";
-    protected static final String TLS_KEYSTORE_PASSWORD_PATH = "tlsKeyStorePasswordPath";
-    protected static final String TLS_TRUSTSTORE_TYPE = "tlsTrustStoreType";
-    protected static final String TLS_TRUSTSTORE = "tlsTrustStore";
-    protected static final String TLS_TRUSTSTORE_PASSWORD_PATH = "tlsTrustStorePasswordPath";
-
     // Lifecycle Components
     protected static final String EXTRA_SERVER_COMPONENTS = "extraServerComponents";
 
@@ -2331,7 +2323,7 @@ public String getTLSKeyStore() {
     /**
      * Set the keystore path for the client.
      *
-     * @return ServerConfiguration
+     * @return
      */
     public ServerConfiguration setTLSKeyStore(String arg) {
         setProperty(TLS_KEYSTORE, arg);
@@ -2415,6 +2407,25 @@ public ServerConfiguration setTLSTrustStorePasswordPath(String arg) {
         return this;
     }
 
+    /**
+     * Get the path to file containing TLS Certificate.
+     *
+     * @return
+     */
+    public String getTLSCertificatePath() {
+        return getString(TLS_CERTIFICATE_PATH, null);
+    }
+
+    /**
+     * Set the path to file containing TLS Certificate.
+     *
+     * @return
+     */
+    public ServerConfiguration setTLSCertificatePath(String arg) {
+        setProperty(TLS_CERTIFICATE_PATH, arg);
+        return this;
+    }
+
 
     /**
      * Whether to enable recording task execution stats.
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieNettyServer.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieNettyServer.java
index dc2cbcefe..3c5385c5c 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieNettyServer.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieNettyServer.java
@@ -223,6 +223,7 @@ public SocketAddress getRemoteAddr() {
                             result.addAll(Arrays.asList(certificates));
                             return result;
                         } catch (SSLPeerUnverifiedException err) {
+                            LOG.error("Failed to get peer certificates", err);
                             return Collections.emptyList();
                         }
 
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/tls/TLSContextFactory.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/tls/TLSContextFactory.java
index a2108a706..2d3f51b2a 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/tls/TLSContextFactory.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/tls/TLSContextFactory.java
@@ -34,8 +34,11 @@
 import java.security.KeyStore;
 import java.security.KeyStoreException;
 import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
 import java.security.UnrecoverableKeyException;
 import java.security.cert.CertificateException;
+import java.security.spec.InvalidKeySpecException;
+import java.util.Arrays;
 
 import javax.net.ssl.KeyManagerFactory;
 import javax.net.ssl.TrustManagerFactory;
@@ -51,6 +54,13 @@
  * A factory to manage TLS contexts.
  */
 public class TLSContextFactory implements SecurityHandlerFactory {
+    /**
+     * Supported Key File Types.
+     */
+    public enum KeyStoreType {
+        PKCS12, JKS, PEM;
+    }
+
     private static final Logger LOG = LoggerFactory.getLogger(TLSContextFactory.class);
     private static final String TLSCONTEXT_HANDLER_NAME = "tls";
     private String[] protocols;
@@ -73,6 +83,7 @@ private String getPasswordFromFile(String path) throws IOException {
     private KeyStore loadKeyStore(String keyStoreType, String keyStoreLocation, String keyStorePassword)
             throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException {
         KeyStore ks = KeyStore.getInstance(keyStoreType);
+
         try (FileInputStream ksin = new FileInputStream(keyStoreLocation)) {
             ks.load(ksin, keyStorePassword.trim().toCharArray());
         }
@@ -85,7 +96,7 @@ public String getHandlerName() {
 
     private KeyManagerFactory initKeyManagerFactory(String keyStoreType, String keyStoreLocation,
             String keyStorePasswordPath) throws SecurityException, KeyStoreException, NoSuchAlgorithmException,
-            CertificateException, IOException, UnrecoverableKeyException {
+            CertificateException, IOException, UnrecoverableKeyException, InvalidKeySpecException {
         KeyManagerFactory kmf = null;
 
         if (Strings.isNullOrEmpty(keyStoreLocation)) {
@@ -98,7 +109,7 @@ private KeyManagerFactory initKeyManagerFactory(String keyStoreType, String keyS
             keyStorePassword = getPasswordFromFile(keyStorePasswordPath);
         }
 
-        // Initialize key store
+        // Initialize key file
         KeyStore ks = loadKeyStore(keyStoreType, keyStoreLocation, keyStorePassword);
         kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
         kmf.init(ks, keyStorePassword.trim().toCharArray());
@@ -121,7 +132,7 @@ private TrustManagerFactory initTrustManagerFactory(String trustStoreType, Strin
             trustStorePassword = getPasswordFromFile(trustStorePasswordPath);
         }
 
-        // Initialize trust store
+        // Initialize trust file
         KeyStore ts = loadKeyStore(trustStoreType, trustStoreLocation, trustStorePassword);
         tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
         tmf.init(ts);
@@ -147,89 +158,179 @@ private SslProvider getTLSProvider(String sslProvider) {
         return SslProvider.JDK;
     }
 
-    private void createClientContext(AbstractConfiguration conf) throws SecurityException, KeyStoreException,
-            NoSuchAlgorithmException, CertificateException, IOException, UnrecoverableKeyException {
+    private void createClientContext(AbstractConfiguration conf)
+            throws SecurityException, KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException,
+            UnrecoverableKeyException, InvalidKeySpecException, NoSuchProviderException {
         final SslContextBuilder sslContextBuilder;
         final ClientConfiguration clientConf;
         final SslProvider provider;
-        final boolean authentication;
-
-        KeyManagerFactory kmf = null;
-        TrustManagerFactory tmf = null;
+        final boolean clientAuthentication;
 
-        // get key-store and trust-store locations and passwords
+        // get key-file and trust-file locations and passwords
         if (!(conf instanceof ClientConfiguration)) {
             throw new SecurityException("Client configruation not provided");
         }
 
         clientConf = (ClientConfiguration) conf;
         provider = getTLSProvider(clientConf.getTLSProvider());
-        authentication = clientConf.getTLSClientAuthentication();
+        clientAuthentication = clientConf.getTLSClientAuthentication();
 
-        tmf = initTrustManagerFactory(clientConf.getTLSTrustStoreType(), clientConf.getTLSTrustStore(),
-                clientConf.getTLSTrustStorePasswordPath());
+        switch (KeyStoreType.valueOf(clientConf.getTLSTrustStoreType())) {
+        case PEM:
+            if (Strings.isNullOrEmpty(clientConf.getTLSTrustStore())) {
+                throw new SecurityException("CA Certificate required");
+            }
 
-        if (authentication) {
-            kmf = initKeyManagerFactory(clientConf.getTLSKeyStoreType(), clientConf.getTLSKeyStore(),
-                    clientConf.getTLSKeyStorePasswordPath());
+            sslContextBuilder = SslContextBuilder.forClient()
+                    .trustManager(new File(clientConf.getTLSTrustStore()))
+                    .ciphers(null)
+                    .sessionCacheSize(0)
+                    .sessionTimeout(0)
+                    .sslProvider(provider)
+                    .clientAuth(ClientAuth.REQUIRE);
+
+            break;
+        case JKS:
+            // falling thru, same as PKCS12
+        case PKCS12:
+            TrustManagerFactory tmf = initTrustManagerFactory(clientConf.getTLSTrustStoreType(),
+                    clientConf.getTLSTrustStore(), clientConf.getTLSTrustStorePasswordPath());
+
+            sslContextBuilder = SslContextBuilder.forClient()
+                    .trustManager(tmf)
+                    .ciphers(null)
+                    .sessionCacheSize(0)
+                    .sessionTimeout(0)
+                    .sslProvider(provider)
+                    .clientAuth(ClientAuth.REQUIRE);
+
+            break;
+        default:
+            throw new SecurityException("Invalid Truststore type: " + clientConf.getTLSTrustStoreType());
         }
 
-        // Build Ssl context
-        sslContextBuilder = SslContextBuilder.forClient()
-                                            .trustManager(tmf)
-                                            .ciphers(null)
-                                            .sessionCacheSize(0)
-                                            .sessionTimeout(0)
-                                            .sslProvider(provider)
-                                            .clientAuth(ClientAuth.REQUIRE);
-
-        /* if mutual authentication is enabled */
-        if (authentication) {
-            sslContextBuilder.keyManager(kmf);
+        if (clientAuthentication) {
+            switch (KeyStoreType.valueOf(clientConf.getTLSKeyStoreType())) {
+            case PEM:
+                final String keyPassword;
+
+                if (Strings.isNullOrEmpty(clientConf.getTLSCertificatePath())) {
+                    throw new SecurityException("Valid Certificate is missing");
+                }
+
+                if (Strings.isNullOrEmpty(clientConf.getTLSKeyStore())) {
+                    throw new SecurityException("Valid Key is missing");
+                }
+
+                if (!Strings.isNullOrEmpty(clientConf.getTLSKeyStorePasswordPath())) {
+                    keyPassword = getPasswordFromFile(clientConf.getTLSKeyStorePasswordPath());
+                } else {
+                    keyPassword = null;
+                }
+
+                sslContextBuilder.keyManager(new File(clientConf.getTLSCertificatePath()),
+                        new File(clientConf.getTLSKeyStore()), keyPassword);
+                break;
+            case JKS:
+                // falling thru, same as PKCS12
+            case PKCS12:
+                KeyManagerFactory kmf = initKeyManagerFactory(clientConf.getTLSKeyStoreType(),
+                        clientConf.getTLSKeyStore(), clientConf.getTLSKeyStorePasswordPath());
+
+                sslContextBuilder.keyManager(kmf);
+                break;
+            default:
+                throw new SecurityException("Invalid Keyfile type" + clientConf.getTLSKeyStoreType());
+            }
         }
 
         sslContext = sslContextBuilder.build();
     }
 
     private void createServerContext(AbstractConfiguration conf) throws SecurityException, KeyStoreException,
-            NoSuchAlgorithmException, CertificateException, IOException, UnrecoverableKeyException {
+            NoSuchAlgorithmException, CertificateException, IOException, UnrecoverableKeyException,
+            InvalidKeySpecException, IllegalArgumentException {
         final SslContextBuilder sslContextBuilder;
         final ServerConfiguration serverConf;
         final SslProvider provider;
-        final boolean authentication;
+        final boolean clientAuthentication;
 
-        KeyManagerFactory kmf = null;
-        TrustManagerFactory tmf = null;
-
-        // get key-store and trust-store locations and passwords
+        // get key-file and trust-file locations and passwords
         if (!(conf instanceof ServerConfiguration)) {
             throw new SecurityException("Server configruation not provided");
         }
 
         serverConf = (ServerConfiguration) conf;
         provider = getTLSProvider(serverConf.getTLSProvider());
-        authentication = serverConf.getTLSClientAuthentication();
+        clientAuthentication = serverConf.getTLSClientAuthentication();
+
+        switch (KeyStoreType.valueOf(serverConf.getTLSKeyStoreType())) {
+        case PEM:
+            final String keyPassword;
+
+            if (Strings.isNullOrEmpty(serverConf.getTLSKeyStore())) {
+                throw new SecurityException("Key path is required");
+            }
+
+            if (Strings.isNullOrEmpty(serverConf.getTLSCertificatePath())) {
+                throw new SecurityException("Certificate path is required");
+            }
 
-        kmf = initKeyManagerFactory(serverConf.getTLSKeyStoreType(), serverConf.getTLSKeyStore(),
-                serverConf.getTLSKeyStorePasswordPath());
+            if (!Strings.isNullOrEmpty(serverConf.getTLSKeyStorePasswordPath())) {
+                keyPassword = getPasswordFromFile(serverConf.getTLSKeyStorePasswordPath());
+            } else {
+                keyPassword = null;
+            }
 
-        if (authentication) {
-            tmf = initTrustManagerFactory(serverConf.getTLSTrustStoreType(), serverConf.getTLSTrustStore(),
-                    serverConf.getTLSTrustStorePasswordPath());
+            sslContextBuilder = SslContextBuilder
+                                .forServer(new File(serverConf.getTLSCertificatePath()),
+                            new File(serverConf.getTLSKeyStore()), keyPassword)
+                                .ciphers(null)
+                                .sessionCacheSize(0)
+                                .sessionTimeout(0)
+                                .sslProvider(provider)
+                                .startTls(true);
+
+            break;
+        case JKS:
+            // falling thru, same as PKCS12
+        case PKCS12:
+            KeyManagerFactory kmf = initKeyManagerFactory(serverConf.getTLSKeyStoreType(),
+                    serverConf.getTLSKeyStore(),
+                    serverConf.getTLSKeyStorePasswordPath());
+
+            sslContextBuilder = SslContextBuilder.forServer(kmf)
+                                .ciphers(null)
+                                .sessionCacheSize(0)
+                                .sessionTimeout(0)
+                                .sslProvider(provider)
+                                .startTls(true);
+
+            break;
+        default:
+            throw new SecurityException("Invalid Keyfile type" + serverConf.getTLSKeyStoreType());
         }
 
-        // Build Ssl context
-        sslContextBuilder = SslContextBuilder.forServer(kmf)
-                                            .ciphers(null)
-                                            .sessionCacheSize(0)
-                                            .sessionTimeout(0)
-                                            .sslProvider(provider)
-                                            .startTls(true);
-
-        /* if mutual authentication is enabled */
-        if (authentication) {
-            sslContextBuilder.trustManager(tmf)
-                            .clientAuth(ClientAuth.REQUIRE);
+        if (clientAuthentication) {
+            sslContextBuilder.clientAuth(ClientAuth.REQUIRE);
+
+            switch (KeyStoreType.valueOf(serverConf.getTLSTrustStoreType())) {
+            case PEM:
+                if (Strings.isNullOrEmpty(serverConf.getTLSTrustStore())) {
+                    throw new SecurityException("CA Certificate chain is required");
+                }
+                sslContextBuilder.trustManager(new File(serverConf.getTLSTrustStore()));
+                break;
+            case JKS:
+                // falling thru, same as PKCS12
+            case PKCS12:
+                TrustManagerFactory tmf = initTrustManagerFactory(serverConf.getTLSTrustStoreType(),
+                        serverConf.getTLSTrustStore(), serverConf.getTLSTrustStorePasswordPath());
+                sslContextBuilder.trustManager(tmf);
+                break;
+            default:
+                throw new SecurityException("Invalid Truststore type" + serverConf.getTLSTrustStoreType());
+            }
         }
 
         sslContext = sslContextBuilder.build();
@@ -269,9 +370,15 @@ public synchronized void init(NodeType type, AbstractConfiguration conf) throws
         } catch (CertificateException e) {
             throw new SecurityException("Unable to load keystore", e);
         } catch (IOException e) {
-            throw new SecurityException("Error initializing TLSContext", e);
+            throw new SecurityException("Error initializing SSLContext", e);
         } catch (UnrecoverableKeyException e) {
-            throw new SecurityException("Unable to load key manager, possibly wrong password given", e);
+            throw new SecurityException("Unable to load key manager, possibly bad password", e);
+        } catch (InvalidKeySpecException e) {
+            throw new SecurityException("Unable to load key manager", e);
+        } catch (IllegalArgumentException e) {
+            throw new SecurityException("Invalid TLS configuration", e);
+        } catch (NoSuchProviderException e) {
+            throw new SecurityException("No such provider", e);
         }
     }
 
@@ -282,10 +389,16 @@ public SslHandler newTLSHandler() {
         if (protocols != null && protocols.length != 0) {
             sslHandler.engine().setEnabledProtocols(protocols);
         }
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Enabled cipher protocols: {} ", Arrays.toString(sslHandler.engine().getEnabledProtocols()));
+        }
 
         if (ciphers != null && ciphers.length != 0) {
             sslHandler.engine().setEnabledCipherSuites(ciphers);
         }
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Enabled cipher suites: {} ", Arrays.toString(sslHandler.engine().getEnabledCipherSuites()));
+        }
 
         return sslHandler;
     }
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/tls/TestTLS.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/tls/TestTLS.java
index 1ba7f9476..501fff839 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/tls/TestTLS.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/tls/TestTLS.java
@@ -55,12 +55,16 @@
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * Tests with TLS enabled.
  */
+@RunWith(Parameterized.class)
 public class TestTLS extends BookKeeperClusterTestCase {
 
     private static final Logger LOG = LoggerFactory.getLogger(TestPerChannelBookieClient.class);
@@ -71,9 +75,28 @@
     private static boolean secureBookieSideChannel = false;
     private static Collection<Object> secureBookieSideChannelPrincipals = null;
 
-
-    public TestTLS() {
+    private TLSContextFactory.KeyStoreType clientKeyStoreFormat;
+    private TLSContextFactory.KeyStoreType clientTrustStoreFormat;
+    private TLSContextFactory.KeyStoreType serverKeyStoreFormat;
+    private TLSContextFactory.KeyStoreType serverTrustStoreFormat;
+
+    @Parameters
+    public static Collection<Object[]> data() {
+        return Arrays.asList(new Object[][] {
+                { "JKS", "JKS" },
+                { "PEM", "PEM" },
+                { "PKCS12", "PKCS12" },
+                { "JKS", "PEM" },
+                { "PEM", "PKCS12" },
+                { "PKCS12", "JKS" }
+            });
+    }
+    public TestTLS(String keyStoreFormat, String trustStoreFormat) {
         super(3);
+        this.clientKeyStoreFormat = TLSContextFactory.KeyStoreType.valueOf(keyStoreFormat);
+        this.clientTrustStoreFormat = TLSContextFactory.KeyStoreType.valueOf(trustStoreFormat);
+        this.serverKeyStoreFormat = TLSContextFactory.KeyStoreType.valueOf(keyStoreFormat);
+        this.serverTrustStoreFormat = TLSContextFactory.KeyStoreType.valueOf(trustStoreFormat);
     }
 
     @Before
@@ -82,30 +105,113 @@ public void setUp() throws Exception {
         /* client configuration */
         baseClientConf.setTLSProviderFactoryClass(TLSContextFactory.class.getName());
         baseClientConf.setTLSClientAuthentication(true);
-        baseClientConf.setTLSKeyStoreType("JKS");
-        baseClientConf.setTLSKeyStore(
-            this.getClass().getClassLoader().getResource("client.jks").toURI().getPath());
-        baseClientConf.setTLSKeyStorePasswordPath(
-            this.getClass().getClassLoader().getResource("keyStoreClientPassword.txt").toURI().getPath());
-        baseClientConf.setTLSTrustStoreType("JKS");
-        baseClientConf.setTLSTrustStore(
-            this.getClass().getClassLoader().getResource("cacerts").toURI().getPath());
-        baseClientConf.setTLSTrustStorePasswordPath(
-            this.getClass().getClassLoader().getResource("trustStorePassword.txt").toURI().getPath());
+
+        switch (clientKeyStoreFormat) {
+        case PEM:
+            baseClientConf.setTLSKeyStoreType("PEM");
+            baseClientConf.setTLSKeyStore(this.getClass().getClassLoader().getResource("client-key.pem").getPath());
+            baseClientConf.setTLSCertificatePath(
+                    this.getClass().getClassLoader().getResource("client-cert.pem").getPath());
+
+            break;
+        case JKS:
+            baseClientConf.setTLSKeyStoreType("JKS");
+            baseClientConf.setTLSKeyStore(this.getClass().getClassLoader().getResource("client-key.jks").getPath());
+            baseClientConf.setTLSKeyStorePasswordPath(
+                    this.getClass().getClassLoader().getResource("keyStoreClientPassword.txt").getPath());
+
+            break;
+        case PKCS12:
+            baseClientConf.setTLSKeyStoreType("PKCS12");
+            baseClientConf.setTLSKeyStore(this.getClass().getClassLoader().getResource("client-key.p12").getPath());
+            baseClientConf.setTLSKeyStorePasswordPath(
+                    this.getClass().getClassLoader().getResource("keyStoreClientPassword.txt").getPath());
+
+            break;
+        default:
+            throw new Exception("Invalid client keystore format" + clientKeyStoreFormat);
+        }
+
+        switch (clientTrustStoreFormat) {
+        case PEM:
+            baseClientConf.setTLSTrustStoreType("PEM");
+            baseClientConf
+                    .setTLSTrustStore(this.getClass().getClassLoader().getResource("server-cert.pem").getPath());
+
+            break;
+        case JKS:
+            baseClientConf.setTLSTrustStoreType("JKS");
+            baseClientConf
+                    .setTLSTrustStore(this.getClass().getClassLoader().getResource("server-key.jks").getPath());
+            baseClientConf.setTLSTrustStorePasswordPath(
+                    this.getClass().getClassLoader().getResource("keyStoreServerPassword.txt").getPath());
+
+            break;
+        case PKCS12:
+            baseClientConf.setTLSTrustStoreType("PKCS12");
+            baseClientConf
+                    .setTLSTrustStore(this.getClass().getClassLoader().getResource("server-key.p12").getPath());
+            baseClientConf.setTLSTrustStorePasswordPath(
+                    this.getClass().getClassLoader().getResource("keyStoreServerPassword.txt").getPath());
+
+            break;
+        default:
+            throw new Exception("Invalid client keystore format" + clientTrustStoreFormat);
+        }
 
         /* server configuration */
         baseConf.setTLSProviderFactoryClass(TLSContextFactory.class.getName());
         baseConf.setTLSClientAuthentication(true);
-        baseConf.setTLSKeyStoreType("JKS");
-        baseConf.setTLSKeyStore(
-            this.getClass().getClassLoader().getResource("server.jks").toURI().getPath());
-        baseConf.setTLSKeyStorePasswordPath(
-            this.getClass().getClassLoader().getResource("keyStoreServerPassword.txt").toURI().getPath());
-        baseConf.setTLSTrustStoreType("JKS");
-        baseConf.setTLSTrustStore(
-            this.getClass().getClassLoader().getResource("cacerts").toURI().getPath());
-        baseConf.setTLSTrustStorePasswordPath(
-            this.getClass().getClassLoader().getResource("trustStorePassword.txt").toURI().getPath());
+
+        switch (serverKeyStoreFormat) {
+        case PEM:
+            baseConf.setTLSKeyStoreType("PEM");
+            baseConf.setTLSKeyStore(this.getClass().getClassLoader().getResource("server-key.pem").getPath());
+            baseConf.setTLSCertificatePath(this.getClass().getClassLoader().getResource("server-cert.pem").getPath());
+
+            break;
+        case JKS:
+            baseConf.setTLSKeyStoreType("JKS");
+            baseConf.setTLSKeyStore(this.getClass().getClassLoader().getResource("server-key.jks").getPath());
+            baseConf.setTLSKeyStorePasswordPath(
+                    this.getClass().getClassLoader().getResource("keyStoreServerPassword.txt").getPath());
+
+            break;
+        case PKCS12:
+            baseConf.setTLSKeyStoreType("PKCS12");
+            baseConf.setTLSKeyStore(this.getClass().getClassLoader().getResource("server-key.p12").getPath());
+            baseConf.setTLSKeyStorePasswordPath(
+                    this.getClass().getClassLoader().getResource("keyStoreServerPassword.txt").getPath());
+
+            break;
+        default:
+            throw new Exception("Invalid server keystore format" + serverKeyStoreFormat);
+        }
+
+        switch (serverTrustStoreFormat) {
+        case PEM:
+            baseConf.setTLSTrustStoreType("PEM");
+            baseConf.setTLSTrustStore(this.getClass().getClassLoader().getResource("client-cert.pem").getPath());
+
+            break;
+        case JKS:
+            baseConf.setTLSTrustStoreType("JKS");
+            baseConf.setTLSTrustStore(this.getClass().getClassLoader().getResource("client-key.jks").getPath());
+            baseConf.setTLSTrustStorePasswordPath(
+                    this.getClass().getClassLoader().getResource("keyStoreClientPassword.txt").getPath());
+
+            break;
+
+        case PKCS12:
+            baseConf.setTLSTrustStoreType("PKCS12");
+            baseConf.setTLSTrustStore(this.getClass().getClassLoader().getResource("client-key.p12").getPath());
+            baseConf.setTLSTrustStorePasswordPath(
+                    this.getClass().getClassLoader().getResource("keyStoreClientPassword.txt").getPath());
+
+            break;
+        default:
+            throw new Exception("Invalid server keystore format" + serverTrustStoreFormat);
+        }
 
         super.setUp();
     }
@@ -119,7 +225,7 @@ public void tearDown() throws Exception {
     /**
      * Verify that a server will not start if tls is enabled but no cert is specified.
      */
-    @Test
+    @Test(timeout = 60000)
     public void testStartTLSServerNoKeyStore() throws Exception {
         ServerConfiguration bookieConf = newServerConfiguration().setTLSKeyStore(null);
 
diff --git a/bookkeeper-server/src/test/resources/cacerts b/bookkeeper-server/src/test/resources/cacerts
deleted file mode 100644
index 5016b0c74..000000000
Binary files a/bookkeeper-server/src/test/resources/cacerts and /dev/null differ
diff --git a/bookkeeper-server/src/test/resources/client-cert.pem b/bookkeeper-server/src/test/resources/client-cert.pem
new file mode 100644
index 000000000..d819f198b
--- /dev/null
+++ b/bookkeeper-server/src/test/resources/client-cert.pem
@@ -0,0 +1,32 @@
+-----BEGIN CERTIFICATE-----
+MIIFmTCCA4GgAwIBAgIJAKJZcAdMXw8CMA0GCSqGSIb3DQEBCwUAMGIxCzAJBgNV
+BAYTAlVTMQswCQYDVQQIDAJDQTEWMBQGA1UEBwwNU2FuIEZyYW5jaXNjbzEOMAwG
+A1UECgwFRHVtbXkxHjAcBgNVBAMMFWFwYWNoZS5ib29ra2VlcGVyLm9yZzAgFw0x
+ODAxMjQxODM2MjRaGA8zMDE3MDUyNzE4MzYyNFowYjELMAkGA1UEBhMCVVMxCzAJ
+BgNVBAgMAkNBMRYwFAYDVQQHDA1TYW4gRnJhbmNpc2NvMQ4wDAYDVQQKDAVEdW1t
+eTEeMBwGA1UEAwwVYXBhY2hlLmJvb2trZWVwZXIub3JnMIICIjANBgkqhkiG9w0B
+AQEFAAOCAg8AMIICCgKCAgEAwdphglnvMv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1fIpxZPj2
+9YlHUYmmt7mf6313VplRL98jqH+U959ueJjQ9RmEMwgUeu3iIN75/kytkpGrMLdC
+WwKlDWBid66TJaPgJ8mBUC9LNlndSe5bzpueN12MFtaLgaWopiB8WU5pEdMV2eze
+auvrUJkobl5n6vAcip1+SfrnY4EvXwdrO2VpIVkEhRWLfxsuthKwobi7/gR2jIa/
+DT/o5eqvdlxHwdIZ0VVPDdUwngQT26VkGozyrBFlhuSkv7pI/8mjFPjYF1vMcQbi
+J6C3C/K9gQp8XXOFm8r3Szqd14yzqigx2SWz4VWY7L7vX2iVs5gNb1/Fnjt2lQ20
+XMCDNoN8tO6kIqv03L4MRue5ISbJx5hcFML1/aLaidpOhWWgEBsH5hhOVdzzAOGF
+vWBXMgfSLxq/cD2ZZARq5ZHhsX1x5BeZfw4zS6dJspxF6Io4CETOOxi6AA3L
+-----END CERTIFICATE-----
diff --git a/bookkeeper-server/src/test/resources/client-key.jks b/bookkeeper-server/src/test/resources/client-key.jks
new file mode 100644
index 000000000..5bd6e53cc
Binary files /dev/null and b/bookkeeper-server/src/test/resources/client-key.jks differ
diff --git a/bookkeeper-server/src/test/resources/client-key.p12 b/bookkeeper-server/src/test/resources/client-key.p12
new file mode 100644
index 000000000..36a950934
Binary files /dev/null and b/bookkeeper-server/src/test/resources/client-key.p12 differ
diff --git a/bookkeeper-server/src/test/resources/client-key.pem b/bookkeeper-server/src/test/resources/client-key.pem
new file mode 100644
index 000000000..d92a0bd1b
--- /dev/null
+++ b/bookkeeper-server/src/test/resources/client-key.pem
@@ -0,0 +1,52 @@
+-----BEGIN PRIVATE KEY-----
+MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDB2mGCWe8y8isS
+MeAF6R5O2D0qZS2Yr3K+IjTEp0/zEwLqvmW9AhdDBxUHYsDvMGXeYjezYNP1ypn4
+Tqr1XPcAX3JX4XbO89xA63c/2E4K8SP1peoy7O9JdBiYb7DuUuGbgzshfsHiyYa9
+eb3Tl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JN9P
+RpyLDqKs2CmCjn0IQ/4f9N9p34LlIOvjV8vywDLuAHX++LJFAA834lLBEbN+O+N7
+yvhKIW8M67vmpsruL75wqv7wiPQkl3r67woyg/+oAFKwF6vRgj2LTkesxitChj+q
+PzxI2MfrPUfEL1lw/poTIN71nIyM+c2WvWBwyMDxAoIBAG4PC5RSYuyKa8CJ73OK
+Vm07gp+2WqdpQUuLUK4iSaCNAYfTs2qbn1fFAuAqJmLYLR8v7UKLLryzhcuH/Ue3
+SkKrHK9Dbma5OEFDxS/CNG91cIqhB0r8wvsLB+wUrW5Wn9qqigiLxlGWu6n0uIzp
+IcofZhJ9DXrepM7wO02hPJ3JPHJVVQtz8g4RtyVJckEyX7Fy7JooazMcEQ22ZQ68
+/d6FuzjqmrW2fdFfFg1oJdYd4pms1Eb+eiJPfOYtI5Gfa6gSclJvLhi7Z7Hd99BQ
+0Cvlfb9vZ7XHnnFZIXglk9mroIUzGUulW8+wQiKHHodkmFEpwuoxk/YUt70yCPvW
+3FUCggEAMLOHunak/3VClEI8eO6eP1JuH+cnlH2Bpj+/34h6QM8A48J/aI63d/2b
+7bas9ZB9iHfvo22Csu3tjOP4vFyCrumx8ilCgiCTY01DOHqR8UHA+OiX2yiQvEn6
+8he/ku6hizT9w1w0tf9NTxOE4Jy9M5UQ1Ol+20Iwjw99rrHyutM6HpIT9UQaLw4y
+a7tr4CF9+X/1Zjz2/He4fZ9h5akt8pHRjQi4oWx8Adi195s+Cdsrxm1NBTMFM7VU
+ywOTiEpvn6gS3PguMFLwhRObp36VBwymrC7ACcJsszqr2OypzQYbi+XyMj9WfQ80
+lZ/dii5O+DlR4aDU90na6bTa5v8ASw==
+-----END PRIVATE KEY-----
diff --git a/bookkeeper-server/src/test/resources/client.jks b/bookkeeper-server/src/test/resources/client.jks
deleted file mode 100644
index a959a9b82..000000000
Binary files a/bookkeeper-server/src/test/resources/client.jks and /dev/null differ
diff --git a/bookkeeper-server/src/test/resources/generateKeysAndCerts.sh b/bookkeeper-server/src/test/resources/generateKeysAndCerts.sh
new file mode 100755
index 000000000..3d8fdb699
--- /dev/null
+++ b/bookkeeper-server/src/test/resources/generateKeysAndCerts.sh
@@ -0,0 +1,76 @@
+#!/usr/bin/env bash
+#
+#/**
+# * Licensed to the Apache Software Foundation (ASF) under one
+# * or more contributor license agreements.  See the NOTICE file
+# * distributed with this work for additional information
+# * regarding copyright ownership.  The ASF licenses this file
+# * to you under the Apache License, Version 2.0 (the
+# * "License"); you may not use this file except in compliance
+# * with the License.  You may obtain a copy of the License at
+# *
+# *     http://www.apache.org/licenses/LICENSE-2.0
+# *
+# * Unless required by applicable law or agreed to in writing, software
+# * distributed under the License is distributed on an "AS IS" BASIS,
+# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# * See the License for the specific language governing permissions and
+# * limitations under the License.
+# */
+
+# This script generates keys and self-signed certificates in
+# PEM, JKS and PKCS12 formats.
+
+# remove existing files.
+rm ./server-key.pem \
+    ./server-key.p12 \
+    ./server-key.jks \
+    ./server-cert.pem \
+    ./client-key.pem \
+    ./client-key.p12 \
+    ./client-key.jks \
+    ./client-cert.pem \
+    ./keyStoreServerPassword.txt \
+    ./keyStoreClientPassword.txt
+
+
+# One line command to create server keys and self signed certificates.
+openssl req \
+        -new \
+        -newkey rsa:4096 \
+        -days 365000 \
+        -nodes \
+        -x509 \
+        -subj "/C=US/ST=CA/L=San Francisco/O=Dummy/CN=apache.bookkeeper.org" \
+        -out server-cert.pem \
+        -keyout server-key.pem
+
+# Convert crt/key to PKCS12 format.
+openssl pkcs12 -export -in server-cert.pem -inkey server-key.pem -out server-key.p12 -passout pass:server
+
+# store password in a file
+echo "server" > keyStoreServerPassword.txt
+
+# Convert crt/key to JKS format.
+keytool -importkeystore -srckeystore server-key.p12 -srcstoretype pkcs12 -srcstorepass server -destkeystore server-key.jks -deststoretype jks -deststorepass server
+
+# One line command to create client keys and self signed certificates.
+openssl req \
+        -new \
+        -newkey rsa:4096 \
+        -days 365000 \
+        -nodes \
+        -x509 \
+        -subj "/C=US/ST=CA/L=San Francisco/O=Dummy/CN=apache.bookkeeper.org" \
+        -out client-cert.pem \
+        -keyout client-key.pem
+
+# Convert crt/key to PKCS12 format.
+openssl pkcs12 -export -in client-cert.pem -inkey client-key.pem -out client-key.p12 -passout pass:client
+
+# store password in a file.
+echo "client" > keyStoreClientPassword.txt
+
+# Convert crt/key to JKS format.
+keytool -importkeystore -srckeystore client-key.p12 -srcstoretype pkcs12 -srcstorepass client -destkeystore client-key.jks -deststoretype jks -deststorepass client
+
diff --git a/bookkeeper-server/src/test/resources/server-cert.pem b/bookkeeper-server/src/test/resources/server-cert.pem
new file mode 100644
index 000000000..b19de519b
--- /dev/null
+++ b/bookkeeper-server/src/test/resources/server-cert.pem
@@ -0,0 +1,32 @@
+-----BEGIN CERTIFICATE-----
+MIIFmTCCA4GgAwIBAgIJAJLN/+fjRP2hMA0GCSqGSIb3DQEBCwUAMGIxCzAJBgNV
+BAYTAlVTMQswCQYDVQQIDAJDQTEWMBQGA1UEBwwNU2FuIEZyYW5jaXNjbzEOMAwG
+A1UECgwFRHVtbXkxHjAcBgNVBAMMFWFwYWNoZS5ib29ra2VlcGVyLm9yZzAgFw0x
+ODAxMjQxODM2MjNaGA8zMDE3MDUyNzE4MzYyM1owYjELMAkGA1UEBhMCVVMxCzAJ
+BgNVBAgMAkNBMRYwFAYDVQQHDA1TYW4gRnJhbmNpc2NvMQ4wDAYDVQQKDAVEdW1t
+eTEeMBwGA1UEAwwVYXBhY2hlLmJvb2trZWVwZXIub3JnMIICIjANBgkqhkiG9w0B
+AQEFAAOCAg8AMIICCgKCAgEAvn6D0jbhA9OLpfuklC3ytUOuBXlFlgWlFEXTyqH8
+P54tH70+EJjmkV6d9kzBZohAL1cWgGwwQUR2MMIYLvKjRGnULkaCJor5WBP5D0wi
+jjTCsVNJcdC4gbEUjCl5HSmP4hPRVEHzFfWS61bJ2KDxAL7GCnAz+10MEr04KX62
+fOLr/eCHG8icfwnQ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BRcDO4uGRp9680QacwUvCOYe
+9Kkpe+iVdVMY2vAyil0ZmJ1oR3wW3hsiwu0RTEU1bKwrePqCR6t4EC6ihygYn0nG
+Y6PkdKMq/hoWjLo0p0iZuYMbbMNYcZWNAwV90eltw57ITyv8EI+D8hJ/b18wzPIA
+91QyqZ8qd7eo+o/YTGY0YzZHSk147pDk4nqK0d0kszr6SxBwx7i0KSsAB4Kvtrj8
+BLTOlCqwMKKmEuwlNNfonINZyjzRY5cTMeuxj8U7LjTamMOQH4kgnQ0FoEX6
+-----END CERTIFICATE-----
diff --git a/bookkeeper-server/src/test/resources/server-key.jks b/bookkeeper-server/src/test/resources/server-key.jks
new file mode 100644
index 000000000..3949b9d6e
Binary files /dev/null and b/bookkeeper-server/src/test/resources/server-key.jks differ
diff --git a/bookkeeper-server/src/test/resources/server-key.p12 b/bookkeeper-server/src/test/resources/server-key.p12
new file mode 100644
index 000000000..ab9c8aa3b
Binary files /dev/null and b/bookkeeper-server/src/test/resources/server-key.p12 differ
diff --git a/bookkeeper-server/src/test/resources/server-key.pem b/bookkeeper-server/src/test/resources/server-key.pem
new file mode 100644
index 000000000..1e2f1ec9c
--- /dev/null
+++ b/bookkeeper-server/src/test/resources/server-key.pem
@@ -0,0 +1,52 @@
+-----BEGIN PRIVATE KEY-----
+MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQC+foPSNuED04ul
++6SULfK1Q64FeUWWBaUURdPKofw/ni0fvT4QmOaRXp32TMFmiEAvVxaAbDBBRHYw
+whgu8qNEadQuRoImivlYE/kPTCKONMKxU0lx0LiBsRSMKXkdKY/iE9FUQfMV9ZLr
+VsnYoPEAvsYKcDP7XQwSvTgpfrZ84uv94IcbyJx/CdDU7Z8mzxwZRzFN4TmT8NX/
+XTeAf/j0rdwUcc83PJVZp3x2BDljQhnUdOH97/ci+xo4+nYS4qh/1a0tiONacIyY
+v0yyYmIGa5963NlWqIhvxY3Fr545HjoKbmWnsPAhetS6tgdOC26C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f/ZSvTBMTCLmjZWjs3jYGtYANXj3aVAoIBAHzg1JKm9H4ErNyx8wgS
+CHsuRkC+DI1qXPft2VLv/LEtFCgxzpyySlJPDSQftKivvheh0mU7ezSlyJARCCak
+WQTc9adm56pVFSn2B+kJQSG8K5XQezX2FK1El8cq6aw+CBq5GlluC3j7MhX8CyVp
+/8BSK2WgemkeBqNinWVSIdQY4MeB1QtWjf3mWrpC3sGTR/n8tY3TTawCiATcB3sC
+PbhYXZUtP9v2arGy9aNUzbSGyFB6dbHnkVL931bVw0mMhgvxZ32xFnMDD/yHPJ13
+/5SDvmeZf0KJJU9TTfypJl9K4n8DFgeHIT9slSGa4WvG1LboHVRVCz9vhTA38CBW
+u/0CggEALh3hL56l5hpyXDwNQHR8XpZkX6rMuJmqD9f/18tM+deGuqj1/FRUYJrt
+/AeaN1UHjugitYDHGu2hLEORdp6mK19ENXcEajKP+f3TUliuBdogqTXCCNu1RS5p
+ru/G47QV0IxlKMxFRChL7pYs2/7PY0Qo37MvtEd6/FS7g95NZasE5ko8swkDbE7C
++F6wNBDFbS3RhIBfIPlr35Tv4sVEl7gAM7JdUqzIEDsmW38RQzIo8F8t1acwfdZ6
+PLVj2hh2JoF9jjMcy9o1VtnBWtoRkSD48+UmvrJuYrjd98XW4VRcq0VVsuOPBE+q
+EJRVpONvEXHus+f1sCUmQYWYuhmJHA==
+-----END PRIVATE KEY-----
diff --git a/bookkeeper-server/src/test/resources/server.jks b/bookkeeper-server/src/test/resources/server.jks
deleted file mode 100644
index aa582e6dd..000000000
Binary files a/bookkeeper-server/src/test/resources/server.jks and /dev/null differ
diff --git a/bookkeeper-server/src/test/resources/trustStorePassword.txt b/bookkeeper-server/src/test/resources/trustStorePassword.txt
deleted file mode 100644
index 1d40192ae..000000000
--- a/bookkeeper-server/src/test/resources/trustStorePassword.txt
+++ /dev/null
@@ -1 +0,0 @@
-changeit


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services