You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by pe...@apache.org on 2022/05/16 13:54:17 UTC

[pulsar] branch master updated: [cleanup][tls] Unified management of JKS certificates (#15456)

This is an automated email from the ASF dual-hosted git repository.

penghui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 73520c350a1 [cleanup][tls] Unified management of JKS certificates (#15456)
73520c350a1 is described below

commit 73520c350a11d40b55c115d854cc7d94ac90c2db
Author: Zixuan Liu <no...@gmail.com>
AuthorDate: Mon May 16 21:54:08 2022 +0800

    [cleanup][tls] Unified management of JKS certificates (#15456)
---
 build/generate_keystores_for_tests.sh              |  61 ------
 pulsar-broker-common/pom.xml                       |  23 +++
 .../JettySslContextFactoryWithKeyStoreTest.java    |  36 ++--
 .../src/test/resources/ssl/jetty_client_key.jks    | Bin 2679 -> 0 bytes
 .../src/test/resources/ssl/jetty_client_trust.jks  | Bin 1207 -> 0 bytes
 .../src/test/resources/ssl/jetty_server_key.jks    | Bin 2679 -> 0 bytes
 .../src/test/resources/ssl/jetty_server_trust.jks  | Bin 1207 -> 0 bytes
 pulsar-broker/pom.xml                              |  23 +++
 .../broker/auth/MockedPulsarServiceBaseTest.java   |  21 +++
 .../client/impl/AdminApiKeyStoreTlsAuthTest.java   |  18 --
 ...eyStoreTlsProducerConsumerTestWithAuthTest.java |  19 +-
 ...toreTlsProducerConsumerTestWithoutAuthTest.java |  18 +-
 .../apache/pulsar/client/impl/KeyStoreTlsTest.java |  47 ++---
 .../authentication/keystoretls/broker.keystore.jks | Bin 3723 -> 0 bytes
 .../keystoretls/broker.truststore.jks              | Bin 838 -> 0 bytes
 .../authentication/keystoretls/client.keystore.jks | Bin 3726 -> 0 bytes
 .../keystoretls/client.truststore.jks              | Bin 838 -> 0 bytes
 .../keystoretls/pulsar_client_trust_npd.jks        | Bin 838 -> 0 bytes
 .../keystoretls/pulsar_server_trust_npd.jks        | Bin 838 -> 0 bytes
 pulsar-common/pom.xml                              | 208 ++++++++++++---------
 .../pulsar/common/util/netty/SslContextTest.java   |  38 ++--
 .../src/test/resources/ssl/jetty_client_key.jks    | Bin 2679 -> 0 bytes
 .../src/test/resources/ssl/jetty_client_trust.jks  | Bin 1207 -> 0 bytes
 .../src/test/resources/ssl/jetty_server_key.jks    | Bin 2679 -> 0 bytes
 .../src/test/resources/ssl/jetty_server_trust.jks  | Bin 1207 -> 0 bytes
 pulsar-proxy/pom.xml                               |  22 +++
 .../proxy/server/ProxyKeyStoreTlsTestWithAuth.java |  17 --
 .../server/ProxyKeyStoreTlsTestWithoutAuth.java    |  16 --
 .../authentication/keystoretls/broker.keystore.jks | Bin 3723 -> 0 bytes
 .../keystoretls/broker.truststore.jks              | Bin 838 -> 0 bytes
 .../authentication/keystoretls/client.keystore.jks | Bin 3726 -> 0 bytes
 .../keystoretls/client.truststore.jks              | Bin 838 -> 0 bytes
 tests/certificate-authority/README.md              |   7 +
 tests/certificate-authority/RemoveJksPassword.java |  45 +++++
 tests/certificate-authority/generate_keystore.sh   |  49 +++++
 .../certificate-authority/jks/broker.keystore.jks  | Bin 0 -> 2254 bytes
 .../jks/broker.truststore.jks                      | Bin 0 -> 978 bytes
 .../jks/broker.truststore.nopassword.jks           | Bin 0 -> 978 bytes
 .../certificate-authority/jks/client.keystore.jks  | Bin 0 -> 2258 bytes
 .../jks/client.truststore.jks                      | Bin 0 -> 980 bytes
 .../jks/client.truststore.nopassword.jks           | Bin 0 -> 980 bytes
 41 files changed, 367 insertions(+), 301 deletions(-)

diff --git a/build/generate_keystores_for_tests.sh b/build/generate_keystores_for_tests.sh
deleted file mode 100755
index 551ce8e9703..00000000000
--- a/build/generate_keystores_for_tests.sh
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/bin/bash -xe
-#
-# 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.
-#
-
-SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
-
-cd /tmp
-mkdir keygendir$$
-cd keygendir$$
-
-# create CA key and cert
-openssl req -x509 -newkey rsa:2048 -passout pass:111111 -keyout ca-key -out ca-cert -days 3650 -sha256 -subj "/CN=CARoot"
-
-COMMON_PARAMS="-storetype JKS -storepass 111111 -keypass 111111 -noprompt"
-
-# create client and broker truststores and keystores
-keytool -import -keystore client.truststore.jks $COMMON_PARAMS -alias CARoot -file ca-cert
-keytool -import -keystore broker.truststore.jks $COMMON_PARAMS -alias CARoot -file ca-cert
-keytool -import -keystore client.keystore.jks $COMMON_PARAMS -alias CARoot -file ca-cert
-keytool -import -keystore broker.keystore.jks $COMMON_PARAMS -alias CARoot -file ca-cert
-
-# create broker key
-keytool -genkeypair -keystore broker.keystore.jks $COMMON_PARAMS -keyalg RSA -alias localhost -validity 3650 \
-  -dname 'CN=localhost,OU=Unknown,O=Unknown,L=Unknown,ST=Unknown,C=Unknown'
-keytool -certreq -keystore broker.keystore.jks $COMMON_PARAMS -alias localhost -file cert-file
-# sign broker key
-openssl x509 -req -CA ca-cert -CAkey ca-key -in cert-file -out cert-signed -days 3650 -CAcreateserial -passin pass:111111
-# import broker key
-keytool -import -keystore broker.keystore.jks $COMMON_PARAMS -alias localhost -file cert-signed
-
-# create client key
-keytool -genkeypair -keystore client.keystore.jks $COMMON_PARAMS -keyalg RSA -alias clientuser -validity 3650 \
-  -dname 'CN=clientuser,OU=Unknown,O=Unknown,L=Unknown,ST=Unknown,C=Unknown'
-keytool  -certreq -keystore client.keystore.jks $COMMON_PARAMS -alias clientuser -file cert-file-client
-# sign client key
-openssl x509 -req -CA ca-cert -CAkey ca-key -in cert-file-client -out cert-signed-client -days 3650 -CAcreateserial -passin pass:111111
-# import client key
-keytool -import -keystore client.keystore.jks $COMMON_PARAMS -alias clientuser -file cert-signed-client
-
-# update keystores used in tests
-cp client.truststore.jks broker.truststore.jks client.keystore.jks broker.keystore.jks $SCRIPT_DIR/../pulsar-broker/src/test/resources/authentication/keystoretls/
-cp client.truststore.jks broker.truststore.jks client.keystore.jks broker.keystore.jks $SCRIPT_DIR/../pulsar-proxy/src/test/resources/authentication/keystoretls/
-
-cd $SCRIPT_DIR
-rm -rf /tmp/keygendir$$
diff --git a/pulsar-broker-common/pom.xml b/pulsar-broker-common/pom.xml
index bee9b76d5a3..a59613ba229 100644
--- a/pulsar-broker-common/pom.xml
+++ b/pulsar-broker-common/pom.xml
@@ -110,6 +110,29 @@
           </execution>
         </executions>
       </plugin>
+
+      <plugin>
+        <artifactId>maven-resources-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>copy-resources</id>
+            <phase>test-compile</phase>
+            <goals>
+              <goal>copy-resources</goal>
+            </goals>
+            <configuration>
+              <outputDirectory>${project.build.testOutputDirectory}/certificate-authority</outputDirectory>
+              <overwrite>true</overwrite>
+              <resources>
+                <resource>
+                  <directory>${project.parent.basedir}/tests/certificate-authority</directory>
+                  <filtering>false</filtering>
+                </resource>
+              </resources>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
 </project>
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/jetty/tls/JettySslContextFactoryWithKeyStoreTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/jetty/tls/JettySslContextFactoryWithKeyStoreTest.java
index 292bd123fdf..c79ea6103d8 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/jetty/tls/JettySslContextFactoryWithKeyStoreTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/jetty/tls/JettySslContextFactoryWithKeyStoreTest.java
@@ -49,16 +49,24 @@ import org.testng.annotations.Test;
 
 @Slf4j
 public class JettySslContextFactoryWithKeyStoreTest {
+    final static String brokerKeyStorePath =
+            Resources.getResource("certificate-authority/jks/broker.keystore.jks").getPath();
+    final static String brokerTrustStorePath =
+            Resources.getResource("certificate-authority/jks/broker.truststore.jks").getPath();
+    final static String clientKeyStorePath =
+            Resources.getResource("certificate-authority/jks/client.keystore.jks").getPath();
+    final static String clientTrustStorePath =
+            Resources.getResource("certificate-authority/jks/client.truststore.jks").getPath();
+    final static String keyStoreType = "JKS";
+    final static String keyStorePassword = "111111";
 
     @Test
     public void testJettyTlsServerTls() throws Exception {
         Server server = new Server();
         List<ServerConnector> connectors = new ArrayList<>();
         SslContextFactory.Server factory = JettySslContextFactory.createServerSslContextWithKeystore(null,
-                "JKS", Resources.getResource("ssl/jetty_server_key.jks").getPath(),
-                "jetty_server_pwd", false, "JKS",
-                Resources.getResource("ssl/jetty_server_trust.jks").getPath(),
-                "jetty_server_pwd", true, null,
+                keyStoreType, brokerKeyStorePath, keyStorePassword, false, keyStoreType,
+                clientTrustStorePath, keyStorePassword, true, null,
                 null, 600);
         factory.setHostnameVerifier((s, sslSession) -> true);
         ServerConnector connector = new ServerConnector(server, factory);
@@ -86,10 +94,8 @@ public class JettySslContextFactoryWithKeyStoreTest {
         Server server = new Server();
         List<ServerConnector> connectors = new ArrayList<>();
         SslContextFactory.Server factory = JettySslContextFactory.createServerSslContextWithKeystore(null,
-                "JKS", Resources.getResource("ssl/jetty_server_key.jks").getPath(),
-                "jetty_server_pwd", false, "JKS",
-                Resources.getResource("ssl/jetty_server_trust.jks").getPath(),
-                "jetty_server_pwd", true, null,
+                keyStoreType, brokerKeyStorePath, keyStorePassword, false, keyStoreType, clientTrustStorePath,
+                keyStorePassword, true, null,
                 new HashSet<String>() {
                     {
                         this.add("TLSv1.3");
@@ -120,10 +126,8 @@ public class JettySslContextFactoryWithKeyStoreTest {
         Server server = new Server();
         List<ServerConnector> connectors = new ArrayList<>();
         SslContextFactory.Server factory = JettySslContextFactory.createServerSslContextWithKeystore(null,
-                "JKS", Resources.getResource("ssl/jetty_server_key.jks").getPath(),
-                "jetty_server_pwd", false, "JKS",
-                Resources.getResource("ssl/jetty_server_trust.jks").getPath(),
-                "jetty_server_pwd", true, new HashSet<String>() {
+                keyStoreType, brokerKeyStorePath, keyStorePassword, false, keyStoreType, clientTrustStorePath,
+                keyStorePassword, true, new HashSet<String>() {
                     {
                         this.add("TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256");
                     }
@@ -155,10 +159,7 @@ public class JettySslContextFactoryWithKeyStoreTest {
     }
 
     private static SSLContext getClientSslContext() {
-        return getSslContext(Resources.getResource("ssl/jetty_client_key.jks").getPath(),
-                "jetty_client_pwd",
-                Resources.getResource("ssl/jetty_client_trust.jks").getPath(),
-                "jetty_client_pwd");
+        return getSslContext(clientKeyStorePath, keyStorePassword, brokerTrustStorePath, keyStorePassword);
     }
 
     private static SSLContext getSslContext(String keyStorePath, String keyStorePassword,
@@ -189,5 +190,4 @@ public class JettySslContextFactoryWithKeyStoreTest {
             return null;
         }
     }
-
-}
\ No newline at end of file
+}
diff --git a/pulsar-broker-common/src/test/resources/ssl/jetty_client_key.jks b/pulsar-broker-common/src/test/resources/ssl/jetty_client_key.jks
deleted file mode 100644
index 2b8ea64347d..00000000000
Binary files a/pulsar-broker-common/src/test/resources/ssl/jetty_client_key.jks and /dev/null differ
diff --git a/pulsar-broker-common/src/test/resources/ssl/jetty_client_trust.jks b/pulsar-broker-common/src/test/resources/ssl/jetty_client_trust.jks
deleted file mode 100644
index 166a2e00fb3..00000000000
Binary files a/pulsar-broker-common/src/test/resources/ssl/jetty_client_trust.jks and /dev/null differ
diff --git a/pulsar-broker-common/src/test/resources/ssl/jetty_server_key.jks b/pulsar-broker-common/src/test/resources/ssl/jetty_server_key.jks
deleted file mode 100644
index b6189b75c8a..00000000000
Binary files a/pulsar-broker-common/src/test/resources/ssl/jetty_server_key.jks and /dev/null differ
diff --git a/pulsar-broker-common/src/test/resources/ssl/jetty_server_trust.jks b/pulsar-broker-common/src/test/resources/ssl/jetty_server_trust.jks
deleted file mode 100644
index b09cc030a71..00000000000
Binary files a/pulsar-broker-common/src/test/resources/ssl/jetty_server_trust.jks and /dev/null differ
diff --git a/pulsar-broker/pom.xml b/pulsar-broker/pom.xml
index 4a3071f0661..8c028bf1fe1 100644
--- a/pulsar-broker/pom.xml
+++ b/pulsar-broker/pom.xml
@@ -541,6 +541,29 @@
           </execution>
         </executions>
       </plugin>
+
+      <plugin>
+        <artifactId>maven-resources-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>copy-resources</id>
+            <phase>test-compile</phase>
+            <goals>
+              <goal>copy-resources</goal>
+            </goals>
+            <configuration>
+              <outputDirectory>${project.build.testOutputDirectory}/certificate-authority</outputDirectory>
+              <overwrite>true</overwrite>
+              <resources>
+                <resource>
+                  <directory>${project.parent.basedir}/tests/certificate-authority</directory>
+                  <filtering>false</filtering>
+                </resource>
+              </resources>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
     <resources>
       <resource>
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/auth/MockedPulsarServiceBaseTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/auth/MockedPulsarServiceBaseTest.java
index 88fe6ece0bb..dd75f6eab3f 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/auth/MockedPulsarServiceBaseTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/auth/MockedPulsarServiceBaseTest.java
@@ -25,6 +25,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 import com.google.common.collect.Sets;
+import com.google.common.io.Resources;
 import com.google.common.util.concurrent.MoreExecutors;
 import io.netty.channel.EventLoopGroup;
 import java.lang.reflect.Field;
@@ -81,6 +82,26 @@ import javax.ws.rs.container.TimeoutHandler;
  * Base class for all tests that need a Pulsar instance without a ZK and BK cluster.
  */
 public abstract class MockedPulsarServiceBaseTest extends TestRetrySupport {
+    public final static String BROKER_KEYSTORE_FILE_PATH =
+            Resources.getResource("certificate-authority/jks/broker.keystore.jks").getPath();
+    public final static String BROKER_TRUSTSTORE_FILE_PATH =
+            Resources.getResource("certificate-authority/jks/broker.truststore.jks").getPath();
+    public final static String BROKER_TRUSTSTORE_NO_PASSWORD_FILE_PATH =
+            Resources.getResource("certificate-authority/jks/broker.truststore.nopassword.jks").getPath();
+    public final static String BROKER_KEYSTORE_PW = "111111";
+    public final static String BROKER_TRUSTSTORE_PW = "111111";
+
+    public final static String CLIENT_KEYSTORE_FILE_PATH =
+            Resources.getResource("certificate-authority/jks/client.keystore.jks").getPath();
+    public final static String CLIENT_TRUSTSTORE_FILE_PATH =
+            Resources.getResource("certificate-authority/jks/client.truststore.jks").getPath();
+    public final static String CLIENT_TRUSTSTORE_NO_PASSWORD_FILE_PATH =
+            Resources.getResource("certificate-authority/jks/client.truststore.nopassword.jks").getPath();
+    public final static String CLIENT_KEYSTORE_PW = "111111";
+    public final static String CLIENT_TRUSTSTORE_PW = "111111";
+
+    public final static String CLIENT_KEYSTORE_CN = "clientuser";
+    public final static String KEYSTORE_TYPE = "JKS";
 
     protected final String DUMMY_VALUE = "DUMMY_VALUE";
     protected final String GLOBAL_DUMMY_VALUE = "GLOBAL_DUMMY_VALUE";
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/AdminApiKeyStoreTlsAuthTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/AdminApiKeyStoreTlsAuthTest.java
index 77533949b87..b030ffe0a1b 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/AdminApiKeyStoreTlsAuthTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/AdminApiKeyStoreTlsAuthTest.java
@@ -62,24 +62,6 @@ import org.testng.annotations.Test;
 @Slf4j
 @Test(groups = "broker-impl")
 public class AdminApiKeyStoreTlsAuthTest extends ProducerConsumerBase {
-
-    protected final String BROKER_KEYSTORE_FILE_PATH =
-            "./src/test/resources/authentication/keystoretls/broker.keystore.jks";
-    protected final String BROKER_TRUSTSTORE_FILE_PATH =
-            "./src/test/resources/authentication/keystoretls/broker.truststore.jks";
-    protected final String BROKER_KEYSTORE_PW = "111111";
-    protected final String BROKER_TRUSTSTORE_PW = "111111";
-
-    protected final String CLIENT_KEYSTORE_FILE_PATH =
-            "./src/test/resources/authentication/keystoretls/client.keystore.jks";
-    protected final String CLIENT_TRUSTSTORE_FILE_PATH =
-            "./src/test/resources/authentication/keystoretls/client.truststore.jks";
-    protected final String CLIENT_KEYSTORE_PW = "111111";
-    protected final String CLIENT_TRUSTSTORE_PW = "111111";
-
-    protected final String CLIENT_KEYSTORE_CN = "clientuser";
-    protected final String KEYSTORE_TYPE = "JKS";
-
     private final String clusterName = "test";
     Set<String> tlsProtocols = Sets.newConcurrentHashSet();
 
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/KeyStoreTlsProducerConsumerTestWithAuthTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/KeyStoreTlsProducerConsumerTestWithAuthTest.java
index f35cf44c0dd..18041d1a928 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/KeyStoreTlsProducerConsumerTestWithAuthTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/KeyStoreTlsProducerConsumerTestWithAuthTest.java
@@ -51,23 +51,6 @@ import org.testng.annotations.Test;
 @Test(groups = "broker-impl")
 public class KeyStoreTlsProducerConsumerTestWithAuthTest extends ProducerConsumerBase {
 
-    protected final String BROKER_KEYSTORE_FILE_PATH =
-            "./src/test/resources/authentication/keystoretls/broker.keystore.jks";
-    protected final String BROKER_TRUSTSTORE_FILE_PATH =
-            "./src/test/resources/authentication/keystoretls/broker.truststore.jks";
-    protected final String BROKER_KEYSTORE_PW = "111111";
-    protected final String BROKER_TRUSTSTORE_PW = "111111";
-
-    protected final String CLIENT_KEYSTORE_FILE_PATH =
-            "./src/test/resources/authentication/keystoretls/client.keystore.jks";
-    protected final String CLIENT_TRUSTSTORE_FILE_PATH =
-            "./src/test/resources/authentication/keystoretls/client.truststore.jks";
-    protected final String CLIENT_KEYSTORE_PW = "111111";
-    protected final String CLIENT_TRUSTSTORE_PW = "111111";
-
-    protected final String CLIENT_KEYSTORE_CN = "clientuser";
-    protected final String KEYSTORE_TYPE = "JKS";
-
     private final String clusterName = "use";
 
     @BeforeMethod
@@ -162,7 +145,7 @@ public class KeyStoreTlsProducerConsumerTestWithAuthTest extends ProducerConsume
                 .brokerServiceUrlTls(pulsar.getBrokerServiceUrlTls())
                 .build());
         admin.tenants().createTenant("my-property",
-                new TenantInfoImpl(Sets.newHashSet("appid1", "appid2"), Sets.newHashSet("use")));
+                new TenantInfoImpl(Sets.newHashSet("appid1", "appid2"), Sets.newHashSet(clusterName)));
         admin.namespaces().createNamespace("my-property/my-ns");
     }
 
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/KeyStoreTlsProducerConsumerTestWithoutAuthTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/KeyStoreTlsProducerConsumerTestWithoutAuthTest.java
index 9c2b5c7ea7a..d0bdf54dc63 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/KeyStoreTlsProducerConsumerTestWithoutAuthTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/KeyStoreTlsProducerConsumerTestWithoutAuthTest.java
@@ -48,22 +48,6 @@ import org.testng.annotations.Test;
 @Slf4j
 @Test(groups = "broker-impl")
 public class KeyStoreTlsProducerConsumerTestWithoutAuthTest extends ProducerConsumerBase {
-    protected final String BROKER_KEYSTORE_FILE_PATH =
-            "./src/test/resources/authentication/keystoretls/broker.keystore.jks";
-    protected final String BROKER_TRUSTSTORE_FILE_PATH =
-            "./src/test/resources/authentication/keystoretls/broker.truststore.jks";
-    protected final String BROKER_KEYSTORE_PW = "111111";
-    protected final String BROKER_TRUSTSTORE_PW = "111111";
-
-    protected final String CLIENT_KEYSTORE_FILE_PATH =
-            "./src/test/resources/authentication/keystoretls/client.keystore.jks";
-    protected final String CLIENT_TRUSTSTORE_FILE_PATH =
-            "./src/test/resources/authentication/keystoretls/client.truststore.jks";
-    protected final String CLIENT_KEYSTORE_PW = "111111";
-    protected final String CLIENT_TRUSTSTORE_PW = "111111";
-
-    protected final String KEYSTORE_TYPE = "JKS";
-
     private final String clusterName = "use";
     Set<String> tlsProtocols = Sets.newConcurrentHashSet();
 
@@ -148,7 +132,7 @@ public class KeyStoreTlsProducerConsumerTestWithoutAuthTest extends ProducerCons
                 .brokerServiceUrlTls(pulsar.getBrokerServiceUrlTls())
                 .build());
         admin.tenants().createTenant("my-property",
-                new TenantInfoImpl(Sets.newHashSet("appid1", "appid2"), Sets.newHashSet("use")));
+                new TenantInfoImpl(Sets.newHashSet("appid1", "appid2"), Sets.newHashSet(clusterName)));
         admin.namespaces().createNamespace("my-property/my-ns");
     }
 
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/KeyStoreTlsTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/KeyStoreTlsTest.java
index 2e839b93f19..c5894ace01d 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/KeyStoreTlsTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/KeyStoreTlsTest.java
@@ -18,8 +18,16 @@
  */
 package org.apache.pulsar.client.impl;
 
-import static org.apache.pulsar.common.util.SecurityUtility.getProvider;
-import java.security.Provider;
+import static org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest.BROKER_KEYSTORE_FILE_PATH;
+import static org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest.BROKER_KEYSTORE_PW;
+import static org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest.BROKER_TRUSTSTORE_FILE_PATH;
+import static org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest.BROKER_TRUSTSTORE_NO_PASSWORD_FILE_PATH;
+import static org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest.CLIENT_KEYSTORE_FILE_PATH;
+import static org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest.CLIENT_KEYSTORE_PW;
+import static org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest.CLIENT_TRUSTSTORE_FILE_PATH;
+import static org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest.CLIENT_TRUSTSTORE_NO_PASSWORD_FILE_PATH;
+import static org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest.CLIENT_TRUSTSTORE_PW;
+import static org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest.KEYSTORE_TYPE;
 import java.util.Collections;
 import org.apache.pulsar.common.util.keystoretls.KeyStoreSSLContext;
 import org.apache.pulsar.common.util.keystoretls.SSLContextValidatorEngine;
@@ -28,29 +36,6 @@ import org.testng.annotations.Test;
 @Test(groups = "broker-impl")
 public class KeyStoreTlsTest {
 
-    protected final String BROKER_KEYSTORE_FILE_PATH =
-            "./src/test/resources/authentication/keystoretls/broker.keystore.jks";
-    protected final String BROKER_TRUSTSTORE_FILE_PATH =
-            "./src/test/resources/authentication/keystoretls/broker.truststore.jks";
-    protected final String BROKER_KEYSTORE_PW = "111111";
-    protected final String BROKER_TRUSTSTORE_PW = "111111";
-
-    protected final String CLIENT_KEYSTORE_FILE_PATH =
-            "./src/test/resources/authentication/keystoretls/client.keystore.jks";
-    protected final String CLIENT_TRUSTSTORE_FILE_PATH =
-            "./src/test/resources/authentication/keystoretls/client.truststore.jks";
-    protected final String CLIENT_KEYSTORE_PW = "111111";
-    protected final String CLIENT_TRUSTSTORE_PW = "111111";
-    protected final String KEYSTORE_TYPE = "JKS";
-
-    protected final String BROKER_TRUSTSTORE_FILE_NPD_PATH =
-            "./src/test/resources/authentication/keystoretls/pulsar_server_trust_npd.jks";
-
-    protected final String CLIENT_TRUSTSTORE_FILE_NPD_PATH =
-            "./src/test/resources/authentication/keystoretls/pulsar_client_trust_npd.jks";
-
-    public static final Provider BC_PROVIDER = getProvider();
-
     @Test(timeOut = 300000)
     public void testValidate() throws Exception {
         KeyStoreSSLContext serverSSLContext = new KeyStoreSSLContext(KeyStoreSSLContext.Mode.SERVER,
@@ -60,8 +45,8 @@ public class KeyStoreTlsTest {
                 BROKER_KEYSTORE_PW,
                 false,
                 KEYSTORE_TYPE,
-                BROKER_TRUSTSTORE_FILE_PATH,
-                BROKER_TRUSTSTORE_PW,
+                CLIENT_TRUSTSTORE_FILE_PATH,
+                CLIENT_TRUSTSTORE_PW,
                 true,
                 null,
                 null);
@@ -74,8 +59,8 @@ public class KeyStoreTlsTest {
                 CLIENT_KEYSTORE_PW,
                 false,
                 KEYSTORE_TYPE,
-                CLIENT_TRUSTSTORE_FILE_PATH,
-                CLIENT_TRUSTSTORE_PW,
+                BROKER_TRUSTSTORE_FILE_PATH,
+                BROKER_KEYSTORE_PW,
                 false,
                 null,
                 // set client's protocol to TLSv1.2 since SSLContextValidatorEngine.validate doesn't handle TLSv1.3
@@ -94,7 +79,7 @@ public class KeyStoreTlsTest {
                 BROKER_KEYSTORE_PW,
                 false,
                 KEYSTORE_TYPE,
-                BROKER_TRUSTSTORE_FILE_NPD_PATH,
+                CLIENT_TRUSTSTORE_NO_PASSWORD_FILE_PATH,
                 null,
                 true,
                 null,
@@ -108,7 +93,7 @@ public class KeyStoreTlsTest {
                 CLIENT_KEYSTORE_PW,
                 false,
                 KEYSTORE_TYPE,
-                CLIENT_TRUSTSTORE_FILE_NPD_PATH,
+                BROKER_TRUSTSTORE_NO_PASSWORD_FILE_PATH,
                 null,
                 false,
                 null,
diff --git a/pulsar-broker/src/test/resources/authentication/keystoretls/broker.keystore.jks b/pulsar-broker/src/test/resources/authentication/keystoretls/broker.keystore.jks
deleted file mode 100644
index 8ef2c6c60ba..00000000000
Binary files a/pulsar-broker/src/test/resources/authentication/keystoretls/broker.keystore.jks and /dev/null differ
diff --git a/pulsar-broker/src/test/resources/authentication/keystoretls/broker.truststore.jks b/pulsar-broker/src/test/resources/authentication/keystoretls/broker.truststore.jks
deleted file mode 100644
index 96f12a38a72..00000000000
Binary files a/pulsar-broker/src/test/resources/authentication/keystoretls/broker.truststore.jks and /dev/null differ
diff --git a/pulsar-broker/src/test/resources/authentication/keystoretls/client.keystore.jks b/pulsar-broker/src/test/resources/authentication/keystoretls/client.keystore.jks
deleted file mode 100644
index 375e2e00bb4..00000000000
Binary files a/pulsar-broker/src/test/resources/authentication/keystoretls/client.keystore.jks and /dev/null differ
diff --git a/pulsar-broker/src/test/resources/authentication/keystoretls/client.truststore.jks b/pulsar-broker/src/test/resources/authentication/keystoretls/client.truststore.jks
deleted file mode 100644
index 210e423145d..00000000000
Binary files a/pulsar-broker/src/test/resources/authentication/keystoretls/client.truststore.jks and /dev/null differ
diff --git a/pulsar-broker/src/test/resources/authentication/keystoretls/pulsar_client_trust_npd.jks b/pulsar-broker/src/test/resources/authentication/keystoretls/pulsar_client_trust_npd.jks
deleted file mode 100644
index 48b299cb7c1..00000000000
Binary files a/pulsar-broker/src/test/resources/authentication/keystoretls/pulsar_client_trust_npd.jks and /dev/null differ
diff --git a/pulsar-broker/src/test/resources/authentication/keystoretls/pulsar_server_trust_npd.jks b/pulsar-broker/src/test/resources/authentication/keystoretls/pulsar_server_trust_npd.jks
deleted file mode 100644
index 9697ecdcc70..00000000000
Binary files a/pulsar-broker/src/test/resources/authentication/keystoretls/pulsar_server_trust_npd.jks and /dev/null differ
diff --git a/pulsar-common/pom.xml b/pulsar-common/pom.xml
index 3fdd470cb24..92029eba6ae 100644
--- a/pulsar-common/pom.xml
+++ b/pulsar-common/pom.xml
@@ -58,8 +58,8 @@
     </dependency>
 
     <dependency>
-        <groupId>com.fasterxml.jackson.core</groupId>
-        <artifactId>jackson-databind</artifactId>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-databind</artifactId>
     </dependency>
 
     <dependency>
@@ -191,10 +191,10 @@
       <version>1.1.7.5</version>
       <scope>test</scope>
     </dependency>
-      <dependency>
-          <groupId>com.google.code.gson</groupId>
-          <artifactId>gson</artifactId>
-      </dependency>
+    <dependency>
+      <groupId>com.google.code.gson</groupId>
+      <artifactId>gson</artifactId>
+    </dependency>
 
     <dependency>
       <groupId>com.beust</groupId>
@@ -209,47 +209,47 @@
   </dependencies>
 
   <build>
-  <plugins>
-    <plugin>
-      <groupId>org.apache.maven.plugins</groupId>
-      <artifactId>maven-compiler-plugin</artifactId>
-      <configuration>
-        <release>${pulsar.client.compiler.release}</release>
-      </configuration>
-    </plugin>
-
-    <plugin>
-      <groupId>org.gaul</groupId>
-      <artifactId>modernizer-maven-plugin</artifactId>
-      <configuration>
-        <failOnViolations>true</failOnViolations>
-        <javaVersion>8</javaVersion>
-      </configuration>
-      <executions>
-        <execution>
-          <id>modernizer</id>
-          <phase>verify</phase>
-          <goals>
-            <goal>modernizer</goal>
-          </goals>
-        </execution>
-      </executions>
-    </plugin>
-
-	<plugin>
-		<groupId>com.github.splunk.lightproto</groupId>
-		<artifactId>lightproto-maven-plugin</artifactId>
-		<version>${lightproto-maven-plugin.version}</version>
-		<executions>
-			<execution>
-				<goals>
-					<goal>generate</goal>
-				</goals>
-			</execution>
-		</executions>
-	</plugin>
-
-    <plugin>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <release>${pulsar.client.compiler.release}</release>
+        </configuration>
+      </plugin>
+
+      <plugin>
+        <groupId>org.gaul</groupId>
+        <artifactId>modernizer-maven-plugin</artifactId>
+        <configuration>
+          <failOnViolations>true</failOnViolations>
+          <javaVersion>8</javaVersion>
+        </configuration>
+        <executions>
+          <execution>
+            <id>modernizer</id>
+            <phase>verify</phase>
+            <goals>
+              <goal>modernizer</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+
+      <plugin>
+        <groupId>com.github.splunk.lightproto</groupId>
+        <artifactId>lightproto-maven-plugin</artifactId>
+        <version>${lightproto-maven-plugin.version}</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>generate</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+
+      <plugin>
         <groupId>pl.project13.maven</groupId>
         <artifactId>git-commit-id-plugin</artifactId>
         <executions>
@@ -271,51 +271,73 @@
             <skip>true</skip>
           </gitDescribe>
         </configuration>
-    </plugin>
-
-    <plugin>
-      <groupId>org.codehaus.mojo</groupId>
-      <artifactId>templating-maven-plugin</artifactId>
-      <version>1.0.0</version>
-      <executions>
-        <execution>
-          <id>filtering-java-templates</id>
-          <goals>
-            <goal>filter-sources</goal>
-          </goals>
-        </execution>
-      </executions>
-    </plugin>
-    <plugin>
-      <groupId>com.github.spotbugs</groupId>
-      <artifactId>spotbugs-maven-plugin</artifactId>
-      <version>${spotbugs-maven-plugin.version}</version>
-      <executions>
-        <execution>
-          <id>spotbugs</id>
-          <phase>verify</phase>
-          <goals>
-            <goal>check</goal>
-          </goals>
-        </execution>
-      </executions>
-      <configuration>
-        <excludeFilterFile>${basedir}/src/main/resources/findbugsExclude.xml</excludeFilterFile>
-      </configuration>
-    </plugin>
-    <plugin>
-      <groupId>org.apache.maven.plugins</groupId>
-      <artifactId>maven-checkstyle-plugin</artifactId>
-      <executions>
-        <execution>
-          <id>checkstyle</id>
-          <phase>verify</phase>
-          <goals>
-            <goal>check</goal>
-          </goals>
-        </execution>
-      </executions>
-    </plugin>
-  </plugins>
+      </plugin>
+
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>templating-maven-plugin</artifactId>
+        <version>1.0.0</version>
+        <executions>
+          <execution>
+            <id>filtering-java-templates</id>
+            <goals>
+              <goal>filter-sources</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>com.github.spotbugs</groupId>
+        <artifactId>spotbugs-maven-plugin</artifactId>
+        <version>${spotbugs-maven-plugin.version}</version>
+        <executions>
+          <execution>
+            <id>spotbugs</id>
+            <phase>verify</phase>
+            <goals>
+              <goal>check</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <excludeFilterFile>${basedir}/src/main/resources/findbugsExclude.xml</excludeFilterFile>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>checkstyle</id>
+            <phase>verify</phase>
+            <goals>
+              <goal>check</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <artifactId>maven-resources-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>copy-resources</id>
+            <phase>test-compile</phase>
+            <goals>
+              <goal>copy-resources</goal>
+            </goals>
+            <configuration>
+              <outputDirectory>${project.build.testOutputDirectory}/certificate-authority</outputDirectory>
+              <overwrite>true</overwrite>
+              <resources>
+                <resource>
+                  <directory>${project.parent.basedir}/tests/certificate-authority</directory>
+                  <filtering>false</filtering>
+                </resource>
+              </resources>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
   </build>
 </project>
diff --git a/pulsar-common/src/test/java/org/apache/pulsar/common/util/netty/SslContextTest.java b/pulsar-common/src/test/java/org/apache/pulsar/common/util/netty/SslContextTest.java
index 0fbd2521ae0..fb035d66a76 100644
--- a/pulsar-common/src/test/java/org/apache/pulsar/common/util/netty/SslContextTest.java
+++ b/pulsar-common/src/test/java/org/apache/pulsar/common/util/netty/SslContextTest.java
@@ -36,6 +36,19 @@ import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
 public class SslContextTest {
+    final static String brokerKeyStorePath =
+            Resources.getResource("certificate-authority/jks/broker.keystore.jks").getPath();
+    final static String brokerTrustStorePath =
+            Resources.getResource("certificate-authority/jks/broker.truststore.jks").getPath();
+    final static String keyStoreType = "JKS";
+    final static String keyStorePassword = "111111";
+
+    final static String caCertPath = Resources.getResource("certificate-authority/certs/ca.cert.pem").getPath();
+    final static String brokerCertPath =
+            Resources.getResource("certificate-authority/server-keys/broker.cert.pem").getPath();
+    final static String brokerKeyPath =
+            Resources.getResource("certificate-authority/server-keys/broker.key-pk8.pem").getPath();
+
     @DataProvider(name = "caCertSslContextDataProvider")
     public static Object[][] getSslContextDataProvider() {
         Set<String> ciphers = new HashSet<>();
@@ -72,11 +85,11 @@ public class SslContextTest {
 
     @Test(dataProvider = "cipherDataProvider")
     public void testServerKeyStoreSSLContext(Set<String> cipher) throws Exception {
-        NettySSLContextAutoRefreshBuilder contextAutoRefreshBuilder = new NettySSLContextAutoRefreshBuilder(null,
-                "JKS", Resources.getResource("ssl/jetty_server_key.jks").getPath(),
-                "jetty_server_pwd", false, "JKS",
-                Resources.getResource("ssl/jetty_server_trust.jks").getPath(),
-                "jetty_server_pwd", true, cipher,
+        NettySSLContextAutoRefreshBuilder contextAutoRefreshBuilder = new NettySSLContextAutoRefreshBuilder(
+                null,
+                keyStoreType, brokerKeyStorePath, keyStorePassword, false,
+                keyStoreType, brokerTrustStorePath, keyStorePassword,
+                true, cipher,
                 null, 600);
         contextAutoRefreshBuilder.update();
     }
@@ -90,9 +103,11 @@ public class SslContextTest {
 
     @Test(dataProvider = "cipherDataProvider")
     public void testClientKeyStoreSSLContext(Set<String> cipher) throws Exception {
-        NettySSLContextAutoRefreshBuilder contextAutoRefreshBuilder = new NettySSLContextAutoRefreshBuilder(null,
-                false, "JKS", Resources.getResource("ssl/jetty_server_trust.jks").getPath(),
-                "jetty_server_pwd", cipher, null, 0, new ClientAuthenticationData());
+        NettySSLContextAutoRefreshBuilder contextAutoRefreshBuilder = new NettySSLContextAutoRefreshBuilder(
+                null,
+                false,
+                keyStoreType, brokerTrustStorePath, keyStorePassword,
+                cipher, null, 0, new ClientAuthenticationData());
         contextAutoRefreshBuilder.update();
     }
 
@@ -100,9 +115,8 @@ public class SslContextTest {
     public void testServerCaCertSslContextWithSslProvider(SslProvider sslProvider, Set<String> ciphers)
             throws GeneralSecurityException, IOException {
         NettyServerSslContextBuilder sslContext = new NettyServerSslContextBuilder(sslProvider,
-                true, Resources.getResource("ssl/my-ca/ca.pem").getPath(),
-                Resources.getResource("ssl/my-ca/server-ca.pem").getPath(),
-                Resources.getResource("ssl/my-ca/server-key.pem").getPath(),
+                true,
+                caCertPath, brokerCertPath, brokerKeyPath,
                 ciphers,
                 null,
                 true, 60);
@@ -119,7 +133,7 @@ public class SslContextTest {
     public void testClientCaCertSslContextWithSslProvider(SslProvider sslProvider, Set<String> ciphers)
             throws GeneralSecurityException, IOException {
         NettyClientSslContextRefresher sslContext = new NettyClientSslContextRefresher(sslProvider,
-                true, Resources.getResource("ssl/my-ca/ca.pem").getPath(),
+                true, caCertPath,
                 null, ciphers, null, 0);
         if (ciphers != null) {
             if (sslProvider == null || sslProvider == SslProvider.OPENSSL) {
diff --git a/pulsar-common/src/test/resources/ssl/jetty_client_key.jks b/pulsar-common/src/test/resources/ssl/jetty_client_key.jks
deleted file mode 100644
index 2b8ea64347d..00000000000
Binary files a/pulsar-common/src/test/resources/ssl/jetty_client_key.jks and /dev/null differ
diff --git a/pulsar-common/src/test/resources/ssl/jetty_client_trust.jks b/pulsar-common/src/test/resources/ssl/jetty_client_trust.jks
deleted file mode 100644
index 166a2e00fb3..00000000000
Binary files a/pulsar-common/src/test/resources/ssl/jetty_client_trust.jks and /dev/null differ
diff --git a/pulsar-common/src/test/resources/ssl/jetty_server_key.jks b/pulsar-common/src/test/resources/ssl/jetty_server_key.jks
deleted file mode 100644
index b6189b75c8a..00000000000
Binary files a/pulsar-common/src/test/resources/ssl/jetty_server_key.jks and /dev/null differ
diff --git a/pulsar-common/src/test/resources/ssl/jetty_server_trust.jks b/pulsar-common/src/test/resources/ssl/jetty_server_trust.jks
deleted file mode 100644
index b09cc030a71..00000000000
Binary files a/pulsar-common/src/test/resources/ssl/jetty_server_trust.jks and /dev/null differ
diff --git a/pulsar-proxy/pom.xml b/pulsar-proxy/pom.xml
index 2976231f213..18d64f105a9 100644
--- a/pulsar-proxy/pom.xml
+++ b/pulsar-proxy/pom.xml
@@ -218,6 +218,28 @@
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <artifactId>maven-resources-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>copy-resources</id>
+            <phase>test-compile</phase>
+            <goals>
+              <goal>copy-resources</goal>
+            </goals>
+            <configuration>
+              <outputDirectory>${project.build.testOutputDirectory}/certificate-authority</outputDirectory>
+              <overwrite>true</overwrite>
+              <resources>
+                <resource>
+                  <directory>${project.parent.basedir}/tests/certificate-authority</directory>
+                  <filtering>false</filtering>
+                </resource>
+              </resources>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
   <profiles>
diff --git a/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyKeyStoreTlsTestWithAuth.java b/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyKeyStoreTlsTestWithAuth.java
index 7f0a5e7ed02..0feb60d8153 100644
--- a/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyKeyStoreTlsTestWithAuth.java
+++ b/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyKeyStoreTlsTestWithAuth.java
@@ -52,23 +52,6 @@ import org.testng.annotations.Test;
 
 @Slf4j
 public class ProxyKeyStoreTlsTestWithAuth extends MockedPulsarServiceBaseTest {
-    protected final String BROKER_KEYSTORE_FILE_PATH =
-            "./src/test/resources/authentication/keystoretls/broker.keystore.jks";
-    protected final String BROKER_TRUSTSTORE_FILE_PATH =
-            "./src/test/resources/authentication/keystoretls/broker.truststore.jks";
-    protected final String BROKER_KEYSTORE_PW = "111111";
-    protected final String BROKER_TRUSTSTORE_PW = "111111";
-
-    protected final String CLIENT_KEYSTORE_FILE_PATH =
-            "./src/test/resources/authentication/keystoretls/client.keystore.jks";
-    protected final String CLIENT_TRUSTSTORE_FILE_PATH =
-            "./src/test/resources/authentication/keystoretls/client.truststore.jks";
-    protected final String CLIENT_KEYSTORE_PW = "111111";
-    protected final String CLIENT_TRUSTSTORE_PW = "111111";
-
-    protected final String CLIENT_KEYSTORE_CN = "clientuser";
-    protected final String KEYSTORE_TYPE = "JKS";
-
     private ProxyService proxyService;
     private ProxyConfiguration proxyConfig = new ProxyConfiguration();
 
diff --git a/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyKeyStoreTlsTestWithoutAuth.java b/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyKeyStoreTlsTestWithoutAuth.java
index c5d7f0dc519..95c30cf768f 100644
--- a/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyKeyStoreTlsTestWithoutAuth.java
+++ b/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyKeyStoreTlsTestWithoutAuth.java
@@ -48,22 +48,6 @@ import org.testng.annotations.Test;
 
 @Slf4j
 public class ProxyKeyStoreTlsTestWithoutAuth extends MockedPulsarServiceBaseTest {
-    protected final String BROKER_KEYSTORE_FILE_PATH =
-            "./src/test/resources/authentication/keystoretls/broker.keystore.jks";
-    protected final String BROKER_TRUSTSTORE_FILE_PATH =
-            "./src/test/resources/authentication/keystoretls/broker.truststore.jks";
-    protected final String BROKER_KEYSTORE_PW = "111111";
-    protected final String BROKER_TRUSTSTORE_PW = "111111";
-
-    protected final String CLIENT_KEYSTORE_FILE_PATH =
-            "./src/test/resources/authentication/keystoretls/client.keystore.jks";
-    protected final String CLIENT_TRUSTSTORE_FILE_PATH =
-            "./src/test/resources/authentication/keystoretls/client.truststore.jks";
-    protected final String CLIENT_KEYSTORE_PW = "111111";
-    protected final String CLIENT_TRUSTSTORE_PW = "111111";
-
-    protected final String KEYSTORE_TYPE = "JKS";
-
     private ProxyService proxyService;
     private ProxyConfiguration proxyConfig = new ProxyConfiguration();
 
diff --git a/pulsar-proxy/src/test/resources/authentication/keystoretls/broker.keystore.jks b/pulsar-proxy/src/test/resources/authentication/keystoretls/broker.keystore.jks
deleted file mode 100644
index 8ef2c6c60ba..00000000000
Binary files a/pulsar-proxy/src/test/resources/authentication/keystoretls/broker.keystore.jks and /dev/null differ
diff --git a/pulsar-proxy/src/test/resources/authentication/keystoretls/broker.truststore.jks b/pulsar-proxy/src/test/resources/authentication/keystoretls/broker.truststore.jks
deleted file mode 100644
index 96f12a38a72..00000000000
Binary files a/pulsar-proxy/src/test/resources/authentication/keystoretls/broker.truststore.jks and /dev/null differ
diff --git a/pulsar-proxy/src/test/resources/authentication/keystoretls/client.keystore.jks b/pulsar-proxy/src/test/resources/authentication/keystoretls/client.keystore.jks
deleted file mode 100644
index 375e2e00bb4..00000000000
Binary files a/pulsar-proxy/src/test/resources/authentication/keystoretls/client.keystore.jks and /dev/null differ
diff --git a/pulsar-proxy/src/test/resources/authentication/keystoretls/client.truststore.jks b/pulsar-proxy/src/test/resources/authentication/keystoretls/client.truststore.jks
deleted file mode 100644
index 210e423145d..00000000000
Binary files a/pulsar-proxy/src/test/resources/authentication/keystoretls/client.truststore.jks and /dev/null differ
diff --git a/tests/certificate-authority/README.md b/tests/certificate-authority/README.md
index 7575c9aaaf7..008120a35f4 100644
--- a/tests/certificate-authority/README.md
+++ b/tests/certificate-authority/README.md
@@ -39,4 +39,11 @@ openssl pkcs8 -topk8 -inform PEM -outform PEM -in client-keys/admin.key.pem -out
 
 The client is then configured with admin.key-pk8.pem and admin.cert.pem.
 
+## JKS
 
+The following command is used to generate the JKS certificate:
+```shell
+./generate_keystore.sh
+```
+
+These certificate type is JKS, password is 111111.
diff --git a/tests/certificate-authority/RemoveJksPassword.java b/tests/certificate-authority/RemoveJksPassword.java
new file mode 100644
index 00000000000..65a26ce3dcc
--- /dev/null
+++ b/tests/certificate-authority/RemoveJksPassword.java
@@ -0,0 +1,45 @@
+/**
+ * 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.
+ */
+
+package main;
+
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.security.KeyStore;
+
+// RemoveJksPassword removes the password from the keystore or truststore
+public class RemoveJksPassword {
+    public static void main(String[] args) {
+        if (args.length != 3) {
+            System.out.println("USAGE: RemoveJksPassword.java [input] [password] [output]");
+            return;
+        }
+
+        String path = args[0];
+        String password = args[1];
+        String outputPath = args[2];
+        try {
+            KeyStore instance = KeyStore.getInstance("JKS");
+            instance.load(new FileInputStream(path), password.toCharArray());
+            instance.store(new FileOutputStream(outputPath), "".toCharArray());
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}
diff --git a/tests/certificate-authority/generate_keystore.sh b/tests/certificate-authority/generate_keystore.sh
new file mode 100755
index 00000000000..cbddd53c456
--- /dev/null
+++ b/tests/certificate-authority/generate_keystore.sh
@@ -0,0 +1,49 @@
+#!/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.
+#
+
+rm -rf jks
+mkdir jks
+cd jks
+
+DAYS=36500
+
+COMMON_PARAMS="-storetype JKS -storepass 111111 -keypass 111111 -noprompt"
+
+# generate keystore
+keytool -genkeypair -keystore broker.keystore.jks $COMMON_PARAMS -keyalg RSA -keysize 2048 -alias broker -validity $DAYS \
+  -dname 'CN=localhost,OU=Unknown,O=Unknown,L=Unknown,ST=Unknown,C=Unknown'
+keytool -genkeypair -keystore client.keystore.jks $COMMON_PARAMS -keyalg RSA -keysize 2048 -alias client -validity $DAYS \
+  -dname 'CN=clientuser,OU=Unknown,O=Unknown,L=Unknown,ST=Unknown,C=Unknown'
+
+# export certificate
+keytool -exportcert -keystore broker.keystore.jks $COMMON_PARAMS -file broker.cer -alias broker
+keytool -exportcert -keystore client.keystore.jks $COMMON_PARAMS -file client.cer -alias client
+
+# generate truststore
+keytool -importcert -keystore client.truststore.jks $COMMON_PARAMS -file client.cer -alias truststore
+keytool -importcert -keystore broker.truststore.jks $COMMON_PARAMS -file broker.cer -alias truststore
+
+# generate a truststore without password
+java ../RemoveJksPassword.java client.truststore.jks 111111 client.truststore.nopassword.jks
+java ../RemoveJksPassword.java broker.truststore.jks 111111 broker.truststore.nopassword.jks
+
+# cleanup
+rm broker.cer
+rm client.cer
diff --git a/tests/certificate-authority/jks/broker.keystore.jks b/tests/certificate-authority/jks/broker.keystore.jks
new file mode 100644
index 00000000000..3495891ce9b
Binary files /dev/null and b/tests/certificate-authority/jks/broker.keystore.jks differ
diff --git a/tests/certificate-authority/jks/broker.truststore.jks b/tests/certificate-authority/jks/broker.truststore.jks
new file mode 100644
index 00000000000..351b22b5af6
Binary files /dev/null and b/tests/certificate-authority/jks/broker.truststore.jks differ
diff --git a/tests/certificate-authority/jks/broker.truststore.nopassword.jks b/tests/certificate-authority/jks/broker.truststore.nopassword.jks
new file mode 100644
index 00000000000..e4d6dff0047
Binary files /dev/null and b/tests/certificate-authority/jks/broker.truststore.nopassword.jks differ
diff --git a/tests/certificate-authority/jks/client.keystore.jks b/tests/certificate-authority/jks/client.keystore.jks
new file mode 100644
index 00000000000..40c6cf4ff2f
Binary files /dev/null and b/tests/certificate-authority/jks/client.keystore.jks differ
diff --git a/tests/certificate-authority/jks/client.truststore.jks b/tests/certificate-authority/jks/client.truststore.jks
new file mode 100644
index 00000000000..d868d77d5db
Binary files /dev/null and b/tests/certificate-authority/jks/client.truststore.jks differ
diff --git a/tests/certificate-authority/jks/client.truststore.nopassword.jks b/tests/certificate-authority/jks/client.truststore.nopassword.jks
new file mode 100644
index 00000000000..22501ae5ec1
Binary files /dev/null and b/tests/certificate-authority/jks/client.truststore.nopassword.jks differ