fapifta commented on code in PR #6943:
URL: https://github.com/apache/ozone/pull/6943#discussion_r1681857008


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/security/ssl/ReloadingX509KeyManager.java:
##########
@@ -67,27 +66,30 @@ public class ReloadingX509KeyManager extends 
X509ExtendedKeyManager {
    * materials are changed.
    */
   private PrivateKey currentPrivateKey;
-  private List<String> currentCertIdsList = new ArrayList<>();
-  private String alias;
+  private List<X509Certificate> currentTrustChain;
+  private final String alias;
 
   /**
    * Construct a <code>Reloading509KeystoreManager</code>.
    *
-   * @param type type of keystore file, typically 'jks'.
-   * @param caClient client to get the private key and certificate materials.
+   * @param type          type of keystore file, typically 'jks'.
+   * @param componentName the name of the component for which the keys are 
created.
+   * @param privateKey    private key for this key manager.
+   * @param trustChain    list of the trusted certificates.
    * @throws IOException
    * @throws GeneralSecurityException
    */
-  public ReloadingX509KeyManager(String type, CertificateClient caClient)
+  public ReloadingX509KeyManager(String type, String componentName, PrivateKey 
privateKey,
+      List<X509Certificate> trustChain)
       throws GeneralSecurityException, IOException {
     this.type = type;
     keyManagerRef = new AtomicReference<>();
-    keyManagerRef.set(loadKeyManager(caClient));
+    this.alias = componentName + "_key";

Review Comment:
   nit: can we move this up by one line before the instantiation of 
keyManagerRef?



##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/client/CertificateClient.java:
##########
@@ -174,15 +175,9 @@ default void assertValidKeysAndCertificate() throws 
OzoneSecurityException {
     }
   }
 
-  /**
-   * Return the store factory for key manager and trust manager for server.
-   */
-  KeyStoresFactory getServerKeyStoresFactory() throws CertificateException;
+  KeyManager getKeyManager() throws CertificateException;

Review Comment:
   If you define the return value of this method to be ReloadingX509KeyManager, 
then you can spare a cast in the methods implementing these and in some tests 
also, while that way the returned object still remains a KeyManager also, so it 
can be set to TLSConfig, and SSLContext and other places as is. This same is 
true for the getTrustManager method where you can use ReloadingX509TrustManager 
instead of TrustManager.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to