From 766ba6b28669b54a6a90c539822661690cf5fa2d Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Wed, 25 Nov 2009 20:42:49 +0000
Subject: [PATCH] Fix for issue 4371 (setup throws NullPointerException when trying to use a PKCS12 certificate) Handle the case where the user provides a certificate without an alias. The code in CertificateManager has been updated to detect this situation. The code in ConfigureDS has also been updated to handle the case where the user does not provide a certificate nickname.
---
opends/src/server/org/opends/server/util/SetupUtils.java | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/opends/src/server/org/opends/server/util/SetupUtils.java b/opends/src/server/org/opends/server/util/SetupUtils.java
index 1877e8a..7033c5d 100644
--- a/opends/src/server/org/opends/server/util/SetupUtils.java
+++ b/opends/src/server/org/opends/server/util/SetupUtils.java
@@ -526,6 +526,34 @@
/**
+ * Export a certificate in a file. It will export the first certificate
+ * defined. This method is required because of the way.
+ *
+ * @param certManager Certificate manager to use.
+ * @param path Path of the output file.
+ *
+ * @throws CertificateEncodingException If the certificate manager cannot
+ * encode the certificate.
+ * @throws IOException If a problem occurs while creating or writing in the
+ * output file.
+ * @throws KeyStoreException If the certificate manager cannot retrieve the
+ * certificate to be exported.
+ */
+ public static void exportCertificate(
+ CertificateManager certManager, String path)
+ throws CertificateEncodingException, IOException, KeyStoreException
+ {
+ String[] aliases = certManager.getCertificateAliases();
+ Certificate certificate = certManager.getCertificate(aliases[0]);
+
+ byte[] certificateBytes = certificate.getEncoded();
+
+ FileOutputStream outputStream = new FileOutputStream(path, false);
+ outputStream.write(certificateBytes);
+ outputStream.close();
+ }
+
+ /**
* Export a certificate in a file.
*
* @param certManager Certificate manager to use.
--
Gitblit v1.10.0