From 4ac4b275bdde78a84b8330e421ce54b11e981049 Mon Sep 17 00:00:00 2001
From: ludovicp <ludovicp@localhost>
Date: Fri, 30 Jul 2010 13:40:30 +0000
Subject: [PATCH] Fix issue 4573 - Admin Connector certificate should use the host name provided by the user in setup. This is achieved by storing the specified hostname in a temporary file under cn=config, which will be used for generating the self-signed certificates and then deleted. If changing or deleting the self-signed certificates, the provided host name is lost and must be manually specified again.

---
 opends/src/server/org/opends/server/admin/AdministrationConnector.java |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/opends/src/server/org/opends/server/admin/AdministrationConnector.java b/opends/src/server/org/opends/server/admin/AdministrationConnector.java
index 58c5bc2..2bd247a 100644
--- a/opends/src/server/org/opends/server/admin/AdministrationConnector.java
+++ b/opends/src/server/org/opends/server/admin/AdministrationConnector.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2006-2009 Sun Microsystems, Inc.
+ *      Copyright 2006-2010 Sun Microsystems, Inc.
  */
 package org.opends.server.admin;
 
@@ -62,6 +62,7 @@
 import org.opends.server.types.InitializationException;
 import org.opends.server.types.ResultCode;
 import org.opends.server.util.CertificateManager;
+import org.opends.server.util.SetupUtils;
 import org.opends.server.admin.std.server.TrustManagerProviderCfg;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.loggers.ErrorLogger;
@@ -69,7 +70,6 @@
 import org.opends.server.types.DebugLogLevel;
 import org.opends.server.types.DirectoryException;
 import org.opends.server.types.FilePermission;
-import org.opends.server.util.SetupUtils;
 
 /**
  * This class is a wrapper on top of LDAPConnectionHandler to manage
@@ -690,8 +690,10 @@
       CertificateManager certManager = new CertificateManager(
           getFullPath(fbKeyManagerConfig.getKeyStoreFile()), fbKeyManagerConfig
               .getKeyStoreType(), pwd);
+      String hostName =
+        SetupUtils.getHostNameForCertificate(DirectoryServer.getServerRoot());
       String subjectDN = "cn="
-          + Rdn.escapeValue(InetAddress.getLocalHost().getHostName()) + ",O="
+          + Rdn.escapeValue(hostName) + ",O="
           + FRIENDLY_NAME + " Self-Signed Certificate";
       certManager.generateSelfSignedCertificate(certAlias, subjectDN,
           ADMIN_CERT_VALIDITY);

--
Gitblit v1.10.0