mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Valery Kharseko
15 hours ago cae292bd84d7397e7ebc97ca7bd471154b7f18b9
opendj-server-legacy/src/main/java/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java
@@ -13,6 +13,7 @@
 *
 * Copyright 2008-2010 Sun Microsystems, Inc.
 * Portions Copyright 2011-2016 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.opends.server.util.cli;
@@ -1603,12 +1604,10 @@
    {
      logger.warn(ERROR_CERTIFICATE_NULL_AUTH_TYPE.get());
    }
    else
    {
      app.println(ApplicationTrustManager.Cause.NOT_TRUSTED.equals(authType)
          ? INFO_CERTIFICATE_NOT_TRUSTED_TEXT_CLI.get(host, port)
          : INFO_CERTIFICATE_NAME_MISMATCH_TEXT_CLI.get(host, port, host, host, port));
    }
    // The explanation only depends on the cause of the rejection, so it must be displayed even
    // when the authentication type is unknown: otherwise the user is prompted to accept a
    // certificate without being told what is wrong with it.
    app.println(getCertificateRejectionMessage(cause, host, port));
    final X509Certificate[] chain = usedTrustManager.getLastRefusedChain();
    if (chain == null)
@@ -1625,6 +1624,21 @@
  }
  /**
   * Returns the message explaining why the certificate presented by the server was rejected.
   *
   * @param cause the reason why the certificate was rejected.
   * @param host the host name of the server.
   * @param port the port of the server.
   * @return the message explaining why the certificate was rejected.
   */
  static LocalizableMessage getCertificateRejectionMessage(ApplicationTrustManager.Cause cause, String host, int port)
  {
    return cause == ApplicationTrustManager.Cause.NOT_TRUSTED
        ? INFO_CERTIFICATE_NOT_TRUSTED_TEXT_CLI.get(host, port)
        : INFO_CERTIFICATE_NAME_MISMATCH_TEXT_CLI.get(host, port, host, host, port);
  }
  /**
   * Sets the heading that is displayed in interactive mode.
   *
   * @param heading