|
39 | 39 | import java.lang.reflect.Method; |
40 | 40 | import java.nio.charset.StandardCharsets; |
41 | 41 | import java.security.GeneralSecurityException; |
| 42 | +import java.security.SecureRandom; |
| 43 | +import java.util.Base64; |
42 | 44 | import java.util.HashMap; |
43 | 45 | import java.util.Map; |
44 | 46 | import java.util.Properties; |
@@ -76,6 +78,7 @@ public class KafkaAgent { |
76 | 78 | private static final byte BROKER_RUNNING_STATE = 3; |
77 | 79 | private static final byte BROKER_RECOVERY_STATE = 2; |
78 | 80 | private static final byte BROKER_UNKNOWN_STATE = 127; |
| 81 | + private static final SecureRandom RANDOM = new SecureRandom(); |
79 | 82 | private Secret caCertSecret; |
80 | 83 | private Secret nodeCertSecret; |
81 | 84 | private MetricName brokerStateName; |
@@ -263,7 +266,10 @@ private SslContextFactory.Server getSSLContextFactory() throws GeneralSecurityEx |
263 | 266 | SslContextFactory.Server sslContextFactory = new SslContextFactory.Server(); |
264 | 267 | sslContextFactory.setTrustStore(KafkaAgentUtils.jksTrustStore(caCertSecret)); |
265 | 268 |
|
266 | | - String password = KafkaAgentUtils.generateRandomPassword(); |
| 269 | + byte[] random = new byte[24]; |
| 270 | + RANDOM.nextBytes(random); |
| 271 | + String password = Base64.getUrlEncoder().withoutPadding().encodeToString(random).substring(0, 32); |
| 272 | + |
267 | 273 | sslContextFactory.setKeyStore(KafkaAgentUtils.jksKeyStore(nodeCertSecret, password.toCharArray())); |
268 | 274 | sslContextFactory.setKeyStorePassword(password); |
269 | 275 | sslContextFactory.setNeedClientAuth(true); |
|
0 commit comments