From d361f42f2fccf7b6f4e23691d0a40f17969e2ec1 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Sat, 28 Nov 2026 09:48:43 +0000
Subject: [PATCH] [#278] Publish missing ADS instance certificates after replication starts (#1338)

---
 opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java |   27 ++++++++++++++++++++++-----
 1 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java b/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java
index fe8d421..7cc96b5 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java
@@ -110,11 +110,9 @@
   private final ObjectClass ocMacKey;
 
   /**
-   * Creates a new instance of this trust store synchronization thread.
+   * Initializes the local instance certificate and loads certificates and secret keys from ADS.
    *
-   * @throws InitializationException in case an exception occurs during
-   * initialization, such as a failure to publish the instance-key-pair
-   * public-key-certificate in ADS.
+   * @throws InitializationException if the local instance certificate cannot be initialized
    */
   public CryptoManagerSync() throws InitializationException
   {
@@ -126,7 +124,7 @@
         POST_RESPONSE_ADD, POST_RESPONSE_MODIFY, POST_RESPONSE_DELETE),
         true);
     try {
-      CryptoManagerImpl.publishInstanceKeyEntryInADS();
+      CryptoManagerImpl.getInstanceKeyCertificateFromLocalTruststore();
     }
     catch (CryptoManagerException ex) {
       throw new InitializationException(ex.getMessageObject());
@@ -167,6 +165,25 @@
     DirectoryServer.registerInternalPlugin(this);
   }
 
+  /**
+   * Publishes the local instance certificate in ADS if its entry is missing.
+   *
+   * @param requireReplication whether to wait for an ADS replication domain to be enabled
+   * @return true if the entry exists or was created, or false if publication must wait
+   * @throws InitializationException if the entry cannot be published
+   */
+  public static boolean publishInstanceKeyEntryInADS(boolean requireReplication) throws InitializationException
+  {
+    try
+    {
+      return CryptoManagerImpl.publishInstanceKeyEntryInADS(requireReplication);
+    }
+    catch (CryptoManagerException ex)
+    {
+      throw new InitializationException(ex.getMessageObject(), ex);
+    }
+  }
+
   private void searchAdminSuffix()
   {
     SearchRequest request = newSearchRequest(adminSuffixDN, SearchScope.WHOLE_SUBTREE, keySearchFilter);

--
Gitblit v1.10.0