[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Pki-devel] [PATCH] 927 Added --serial param to pki ca-cert-request-submit.



A new parameter has been added to set the serial number field in
CertEnrollmentRequest and in profile input if available.

Pushed to master under trivial rule.

--
Endi S. Dewata
>From e7b589d83cdcde960d1f24993f9bfff971d6963a Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata redhat com>
Date: Thu, 2 Feb 2017 01:13:35 +0100
Subject: [PATCH] Added --serial param to pki ca-cert-request-submit.

A new parameter has been added to set the serial number field in
CertEnrollmentRequest and in profile input if available.
---
 .../cmstools/cert/CertRequestSubmitCLI.java        | 23 ++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/base/java-tools/src/com/netscape/cmstools/cert/CertRequestSubmitCLI.java b/base/java-tools/src/com/netscape/cmstools/cert/CertRequestSubmitCLI.java
index 6223a8e66d52c2142da67155ab0d70f72a7db427..e49dba2406a07697468855c93b71735849527256 100644
--- a/base/java-tools/src/com/netscape/cmstools/cert/CertRequestSubmitCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cert/CertRequestSubmitCLI.java
@@ -16,6 +16,7 @@ import org.apache.commons.cli.Option;
 import com.netscape.certsrv.ca.AuthorityID;
 import com.netscape.certsrv.cert.CertEnrollmentRequest;
 import com.netscape.certsrv.cert.CertRequestInfos;
+import com.netscape.certsrv.dbs.certdb.CertId;
 import com.netscape.certsrv.profile.ProfileAttribute;
 import com.netscape.certsrv.profile.ProfileInput;
 import com.netscape.cmstools.cli.CLI;
@@ -63,6 +64,10 @@ public class CertRequestSubmitCLI extends CLI {
         option.setArgName("path");
         options.addOption(option);
 
+        option = new Option(null, "serial", true, "Serial number of certificate for renewal");
+        option.setArgName("number");
+        options.addOption(option);
+
         option = new Option(null, "subject", true, "Subject DN");
         option.setArgName("DN");
         options.addOption(option);
@@ -177,6 +182,24 @@ public class CertRequestSubmitCLI extends CLI {
             }
         }
 
+        String serial = cmd.getOptionValue("serial");
+        if (serial != null) {
+
+            if (verbose) {
+                System.out.println("Serial: " + serial);
+            }
+
+            request.setSerialNum(new CertId(serial));
+
+            // store serial number in profile input if available
+            for (ProfileInput input : request.getInputs()) {
+                ProfileAttribute serialAttr = input.getAttribute("serial_num");
+                if (serialAttr != null) {
+                    serialAttr.setValue(serial);
+                }
+            }
+        }
+
         String subjectDN = cmd.getOptionValue("subject");
         if (subjectDN != null) {
             DN dn = new DN(subjectDN);
-- 
2.5.5


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]