10e13a
From 3c763332adc224d0e325502cb3e5b97d4155bb0c Mon Sep 17 00:00:00 2001
6696b9
From: Jan Cholasta <jcholast@redhat.com>
6696b9
Date: Fri, 7 Aug 2015 13:40:41 +0200
6696b9
Subject: [PATCH] Remove rekey feature
6696b9
6696b9
https://bugzilla.redhat.com/show_bug.cgi?id=1250397
6696b9
---
6696b9
 src/certmonger-scep-submit.8.in |  8 --------
6696b9
 src/certmonger.conf.5.in        | 19 -------------------
6696b9
 src/getcert-add-scep-ca.1.in    |  8 --------
6696b9
 src/getcert.c                   |  3 ---
6696b9
 src/prefs.c                     | 27 +--------------------------
6696b9
 src/scep.c                      |  5 -----
6696b9
 src/submit-e.c                  |  6 ------
6696b9
 src/tdbush.c                    | 10 +---------
6696b9
 tests/010-iterate/expected.out  | 14 +++++---------
6696b9
 tests/028-dbus/expected.out     |  6 ------
6696b9
 tests/036-getcert/expected.out  | 26 ++++++++++++++------------
6696b9
 tests/037-rekey2/expected.out   |  4 ++--
6696b9
 12 files changed, 23 insertions(+), 113 deletions(-)
6696b9
6696b9
diff --git a/src/certmonger-scep-submit.8.in b/src/certmonger-scep-submit.8.in
10e13a
index 7319c6a..31203c3 100644
6696b9
--- a/src/certmonger-scep-submit.8.in
6696b9
+++ b/src/certmonger-scep-submit.8.in
6696b9
@@ -80,14 +80,6 @@ When called with the \fB-c\fR or \fB-C\fR flag, this option can be used to
6696b9
 specify the CA identifier which is passed to the server as part of the client's
6696b9
 request.  The default is "0".
6696b9
 .TP
6696b9
-\fB\-n\fR
6696b9
-The SCEP Renewal feature allows a client with a previously-issued certificate
6696b9
-to use that certificate and the associated private key to request a new
6696b9
-certificate for a different key pair, and can be used to support
6696b9
-\fIcertmonger\fR's rekeying feature if the SCEP server advertises support for
6696b9
-it.  This option forces the \fIscep-submit\fR helper to prefer to issue
6696b9
-requests which do not make use of this feature.
6696b9
-.TP
6696b9
 \fB-v\fR
6696b9
 Increases the logging level.  Use twice for more logging.  This option
6696b9
 is mainly useful for troubleshooting.
6696b9
diff --git a/src/certmonger.conf.5.in b/src/certmonger.conf.5.in
10e13a
index 241f48b..e1220f1 100644
6696b9
--- a/src/certmonger.conf.5.in
6696b9
+++ b/src/certmonger.conf.5.in
6696b9
@@ -72,25 +72,6 @@ These are the trust attributes which are applied to certificates which are not
6696b9
 necessarily to be trusted, when they are saved to NSS databases.  The default
6696b9
 is \fI,,\fP.
6696b9
 
6696b9
-.IP max_key_use_count
6696b9
-When attempting to replace a certificate, if \fIcertmonger\fR has previously
6696b9
-obtained at least this number of certificates using the current key pair, it
6696b9
-will generate a new key pair to use before proceeding.  There is effectively no
6696b9
-default for this setting.
6696b9
-
6696b9
-.IP max_key_lifetime
6696b9
-The amount of time after a key was first generated when \fIcertmonger\fR will
6696b9
-attempt to generate a new key pair to replace it, as part of the process of
6696b9
-replacing a certificate.
6696b9
-The value is specified as a combination of years (y), months (M), weeks (w),
6696b9
-days (d), hours (h), minutes (m), and/or seconds (s).  If no unit of time is
6696b9
-specified, seconds are assumed.
6696b9
-The date when a key was generated is not recorded if the key was not generated
6696b9
-by \fIcertmonger\fR, or if the key was generated with a version of
6696b9
-\fIcertmonger\fR older than 0.78, and for those cases, this option has no
6696b9
-effect.
6696b9
-There is effectively no default for this setting.
6696b9
-
6696b9
 .SH SELFSIGN
6696b9
 Within the \fIselfsign\fR section, these variables and values are recognized:
6696b9
 
6696b9
diff --git a/src/getcert-add-scep-ca.1.in b/src/getcert-add-scep-ca.1.in
10e13a
index f07b900..64f0f5e 100644
6696b9
--- a/src/getcert-add-scep-ca.1.in
6696b9
+++ b/src/getcert-add-scep-ca.1.in
6696b9
@@ -46,14 +46,6 @@ A CA identifier value which will passed to the server when the
6696b9
 \fIscep-submit\fR helper is used to retrieve copies of the server's
6696b9
 certificates.
6696b9
 .TP
6696b9
-\fB\-n\fR
6696b9
-The SCEP Renewal feature allows a client with a previously-issued certificate
6696b9
-to use that certificate and the associated private key to request a new
6696b9
-certificate for a different key pair, and can be used to support
6696b9
-\fIcertmonger\fR's rekeying feature if the SCEP server advertises support for
6696b9
-it.  This option forces the \fIscep-submit\fR helper to issue requests without
6696b9
-making use of this feature.
6696b9
-.TP
6696b9
 \fB\-v\fR
6696b9
 Be verbose about errors.  Normally, the details of an error received from
6696b9
 the daemon will be suppressed if the client can make a diagnostic suggestion.
6696b9
diff --git a/src/getcert.c b/src/getcert.c
10e13a
index 26a88f3..966ff41 100644
6696b9
--- a/src/getcert.c
6696b9
+++ b/src/getcert.c
10e13a
@@ -4663,7 +4663,6 @@ static struct {
6696b9
 	{"start-tracking", start_tracking},
6696b9
 	{"stop-tracking", stop_tracking},
6696b9
 	{"resubmit", resubmit},
6696b9
-	{"rekey", rekey},
6696b9
 	{"refresh", refresh},
6696b9
 	{"list", list},
6696b9
 	{"status", status},
10e13a
@@ -5087,8 +5086,6 @@ help(const char *twopartcmd, const char *category)
6696b9
 		 N_("stop monitoring a certificate\n")},
6696b9
 		{"resubmit", resubmit_help,
6696b9
 		 N_("resubmit an in-progress enrollment request, or start a new one\n")},
6696b9
-		{"rekey", rekey_help,
6696b9
-		 N_("generate a new private key and replace a certificate\n")},
6696b9
 		{"refresh", refresh_help,
6696b9
 		 N_("check on the status of an in-progress enrollment request\n")},
6696b9
 		{"list", list_help,
6696b9
diff --git a/src/prefs.c b/src/prefs.c
10e13a
index ab363bb..0a8e166 100644
6696b9
--- a/src/prefs.c
6696b9
+++ b/src/prefs.c
6696b9
@@ -545,36 +545,11 @@ cm_prefs_nss_other_trust(void)
6696b9
 long long
6696b9
 prefs_key_end_of_life(time_t ref)
6696b9
 {
6696b9
-	const char *cfg;
6696b9
-	time_t tmp;
6696b9
-
6696b9
-	tmp = -1;
6696b9
-	cfg = cm_prefs_config(NULL, "max_key_lifetime");
6696b9
-	if (cfg != NULL) {
6696b9
-		if (cm_submit_u_delta_from_string(cfg, ref, &tmp) == 0) {
6696b9
-			return tmp;
6696b9
-		}
6696b9
-	}
6696b9
 	return -1;
6696b9
 }
6696b9
 
6696b9
 long
6696b9
 prefs_max_key_use_count(void)
6696b9
 {
6696b9
-	static long count = -2;
6696b9
-	long tmp;
6696b9
-	const char *cfg;
6696b9
-	char *p;
6696b9
-
6696b9
-	if (count == -2) {
6696b9
-		count = -1;
6696b9
-		cfg = cm_prefs_config(NULL, "max_key_use_count");
6696b9
-		if (cfg != NULL) {
6696b9
-			tmp = strtol(cfg, &p, 10);
6696b9
-			if ((p != NULL) && (*p == '\0')) {
6696b9
-				count = tmp;
6696b9
-			}
6696b9
-		}
6696b9
-	}
6696b9
-	return count;
6696b9
+	return -1;
6696b9
 }
6696b9
diff --git a/src/scep.c b/src/scep.c
10e13a
index d3bbc05..11f9ae3 100644
6696b9
--- a/src/scep.c
6696b9
+++ b/src/scep.c
6696b9
@@ -231,7 +231,6 @@ main(int argc, const char **argv)
6696b9
 		{"racert", 'r', POPT_ARG_STRING, NULL, 'r', "the RA certificate, used for encrypting requests", "FILENAME"},
6696b9
 		{"cacert", 'R', POPT_ARG_STRING, NULL, 'R', "the CA certificate, used for verifying responses", "FILENAME"},
6696b9
 		{"other-certs", 'I', POPT_ARG_STRING, NULL, 'I', "additional certificates", "FILENAME"},
6696b9
-		{"non-renewal", 'n', POPT_ARG_NONE, &prefer_non_renewal, 0, "prefer to not use the SCEP Renewal feature", NULL},
6696b9
 		{"verbose", 'v', POPT_ARG_NONE, NULL, 'v', NULL, NULL},
6696b9
 		POPT_AUTOHELP
6696b9
 		POPT_TABLEEND
6696b9
@@ -255,8 +254,6 @@ main(int argc, const char **argv)
6696b9
 			message = getenv(CM_SUBMIT_SCEP_PKCSREQ_REKEY_ENV);
6696b9
 			if (message == NULL) {
6696b9
 				message = getenv(CM_SUBMIT_SCEP_PKCSREQ_ENV);
6696b9
-			} else {
6696b9
-				rekey_message = getenv(CM_SUBMIT_SCEP_PKCSREQ_ENV);
6696b9
 			}
6696b9
 		} else
6696b9
 		if (strcasecmp(mode, CM_OP_POLL) == 0) {
6696b9
@@ -264,8 +261,6 @@ main(int argc, const char **argv)
6696b9
 			message = getenv(CM_SUBMIT_SCEP_PKCSREQ_REKEY_ENV);
6696b9
 			if (message == NULL) {
6696b9
 				message = getenv(CM_SUBMIT_SCEP_PKCSREQ_ENV);
6696b9
-			} else {
6696b9
-				rekey_message = getenv(CM_SUBMIT_SCEP_PKCSREQ_ENV);
6696b9
 			}
6696b9
 		} else
6696b9
 		if (strcasecmp(mode, CM_OP_FETCH_SCEP_CA_CERTS) == 0) {
6696b9
diff --git a/src/submit-e.c b/src/submit-e.c
10e13a
index befd01e..af05efe 100644
6696b9
--- a/src/submit-e.c
6696b9
+++ b/src/submit-e.c
6696b9
@@ -446,12 +446,6 @@ cm_submit_e_need_scep_messages(struct cm_submit_state *state)
6696b9
 static int
6696b9
 cm_submit_e_need_rekey(struct cm_submit_state *state)
6696b9
 {
6696b9
-	int status;
6696b9
-	status = cm_subproc_get_exitstatus(state->subproc);
6696b9
-	if (WIFEXITED(status) &&
6696b9
-	    (WEXITSTATUS(status) == CM_SUBMIT_STATUS_NEED_REKEY)) {
6696b9
-		return 0;
6696b9
-	}
6696b9
 	return -1;
6696b9
 }
6696b9
 
6696b9
diff --git a/src/tdbush.c b/src/tdbush.c
10e13a
index 7fb3d16..04fe57e 100644
6696b9
--- a/src/tdbush.c
6696b9
+++ b/src/tdbush.c
10e13a
@@ -7164,14 +7164,6 @@ cm_tdbush_iface_request(void)
10e13a
 										     cm_tdbush_method_arg_out,
6696b9
 										     NULL))),
6696b9
 								     NULL),
10e13a
-				     make_interface_item(cm_tdbush_interface_method,
6696b9
-							 make_method("rekey",
6696b9
-								     request_rekey,
6696b9
-								     make_method_arg("working",
6696b9
-										     DBUS_TYPE_BOOLEAN_AS_STRING,
6696b9
-										     cm_tdbush_method_arg_out,
6696b9
-										     NULL),
6696b9
-								     NULL),
10e13a
 				     make_interface_item(cm_tdbush_interface_method,
6696b9
 							 make_method("resubmit",
6696b9
 								     request_resubmit,
10e13a
@@ -7227,7 +7219,7 @@ cm_tdbush_iface_request(void)
6696b9
 				     make_interface_item(cm_tdbush_interface_signal,
6696b9
 							 make_signal(CM_DBUS_SIGNAL_REQUEST_CERT_SAVED,
6696b9
 								     NULL),
10e13a
-							 NULL)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))));
10e13a
+							 NULL))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))));
6696b9
 	}
6696b9
 	return ret;
6696b9
 }
6696b9
diff --git a/tests/010-iterate/expected.out b/tests/010-iterate/expected.out
10e13a
index bd57a01..85d07b3 100644
6696b9
--- a/tests/010-iterate/expected.out
6696b9
+++ b/tests/010-iterate/expected.out
6696b9
@@ -398,19 +398,15 @@ HAVE_CSR
6696b9
 -START-
6696b9
 NEED_TO_SUBMIT
6696b9
 SUBMITTING
6696b9
-NEED_KEY_PAIR
6696b9
+NEED_GUIDANCE
6696b9
 -STOP-
6696b9
-NEED_KEY_PAIR
6696b9
+NEED_GUIDANCE
6696b9
 -START-
6696b9
-GENERATING_KEY_PAIR
6696b9
-HAVE_KEY_PAIR
6696b9
-NEED_KEYINFO
6696b9
+NEED_GUIDANCE
6696b9
 -STOP-
6696b9
-NEED_KEYINFO
6696b9
+NEED_GUIDANCE
6696b9
 -START-
6696b9
-READING_KEYINFO
6696b9
-HAVE_KEYINFO
6696b9
-NEED_CSR
6696b9
+NEED_GUIDANCE
6696b9
 -STOP-
6696b9
 
6696b9
 [Enroll until we notice we have no specified CA.]
6696b9
diff --git a/tests/028-dbus/expected.out b/tests/028-dbus/expected.out
10e13a
index 8a81a7f..4c33e9a 100644
6696b9
--- a/tests/028-dbus/expected.out
6696b9
+++ b/tests/028-dbus/expected.out
10e13a
@@ -404,9 +404,6 @@ OK
6696b9
    <arg name="status" type="b" direction="out"/>
6696b9
    <arg name="path" type="o" direction="out"/>
6696b9
   </method>
6696b9
-  <method name="rekey">
6696b9
-   <arg name="working" type="b" direction="out"/>
6696b9
-  </method>
6696b9
   <method name="resubmit">
6696b9
    <arg name="working" type="b" direction="out"/>
6696b9
   </method>
10e13a
@@ -484,9 +481,6 @@ recently
6696b9
 1 on /org/fedorahosted/certmonger/requests/Request2
6696b9
 After setting template-eku to 1.2.3.4.5.6.7.8.9.10, we got dbus.Array([dbus.String(u'1.2.3.4.5.6.7.8.9.10')], signature=dbus.Signature('s'), variant_level=1)
6696b9
 
6696b9
-[ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.rekey ]
6696b9
-1
6696b9
-
6696b9
 [ /org/fedorahosted/certmonger/requests/Request2: org.fedorahosted.certmonger.request.resubmit ]
6696b9
 1
6696b9
 
6696b9
diff --git a/tests/036-getcert/expected.out b/tests/036-getcert/expected.out
10e13a
index c1a13c8..b6d1eaf 100644
6696b9
--- a/tests/036-getcert/expected.out
6696b9
+++ b/tests/036-getcert/expected.out
6696b9
@@ -11,20 +11,21 @@ certs:1
6696b9
 keys:1
6696b9
 -----BEGIN PRIVATE KEY-----
6696b9
 [Files, rekey]
6696b9
-Resubmitting "first" to "local".
6696b9
 certs:1
6696b9
 -----BEGIN CERTIFICATE-----
6696b9
 keys:1
6696b9
 -----BEGIN PRIVATE KEY-----
6696b9
+ERROR: keys were not changed on rekey
6696b9
+ERROR: cert was not changed on rekey
6696b9
 [Files, rekey with preserve=1]
6696b9
-Resubmitting "first" to "local".
6696b9
 certs:1
6696b9
 -----BEGIN CERTIFICATE-----
6696b9
-keys:2
6696b9
------BEGIN PRIVATE KEY-----
6696b9
+keys:1
6696b9
 -----BEGIN PRIVATE KEY-----
6696b9
+ERROR: keys were not changed on rekey
6696b9
+ERROR: cert was not changed on rekey
6696b9
+ERROR: old keys were not saved on rekey
6696b9
 [Files, rekey with jerk CA]
6696b9
-Resubmitting "first" to "jerkca".
6696b9
 certs:1
6696b9
 -----BEGIN CERTIFICATE-----
6696b9
 keys:1
6696b9
@@ -44,30 +45,31 @@ pk12util: PKCS12 EXPORT SUCCESSFUL
6696b9
 cert:1
6696b9
 key:1
6696b9
 [Database, rekey]
6696b9
-Resubmitting "first" to "local".
6696b9
 certs:1
6696b9
 keys:1
6696b9
 pk12util: PKCS12 EXPORT SUCCESSFUL
6696b9
 cert:1
6696b9
 key:1
6696b9
+ERROR: keys were not changed on rekey
6696b9
+ERROR: cert was not changed on rekey
6696b9
 [Database, rekey with preserve=1]
6696b9
-Resubmitting "first" to "local".
6696b9
 certs:1
6696b9
-keys:2
6696b9
+keys:1
6696b9
 pk12util: PKCS12 EXPORT SUCCESSFUL
6696b9
 cert:1
6696b9
 key:1
6696b9
+ERROR: keys were not changed on rekey
6696b9
+ERROR: cert was not changed on rekey
6696b9
+ERROR: old keys were not saved on rekey
6696b9
 [Database, rekey with jerk CA]
6696b9
-Resubmitting "first" to "jerkca".
6696b9
 certs:1
6696b9
-keys:3
6696b9
+keys:1
6696b9
 pk12util: PKCS12 EXPORT SUCCESSFUL
6696b9
 cert:1
6696b9
 key:1
6696b9
 [Database, rekey with jerk CA, nonpreserving]
6696b9
-Resubmitting "first" to "jerkca".
6696b9
 certs:1
6696b9
-keys:3
6696b9
+keys:1
6696b9
 pk12util: PKCS12 EXPORT SUCCESSFUL
6696b9
 cert:1
6696b9
 key:1
6696b9
diff --git a/tests/037-rekey2/expected.out b/tests/037-rekey2/expected.out
10e13a
index bd8cca7..62a1c74 100644
6696b9
--- a/tests/037-rekey2/expected.out
6696b9
+++ b/tests/037-rekey2/expected.out
6696b9
@@ -112,7 +112,7 @@ MONITORING
6696b9
 -STOP-
6696b9
 MONITORING
6696b9
 -START-
6696b9
-NEED_KEY_PAIR
6696b9
+NEED_CSR
6696b9
 -STOP-
6696b9
 [Uses = 2.]
6696b9
 NEED_KEY_PAIR
6696b9
@@ -228,6 +228,6 @@ MONITORING
6696b9
 -STOP-
6696b9
 MONITORING
6696b9
 -START-
6696b9
-NEED_KEY_PAIR
6696b9
+NEED_CSR
6696b9
 -STOP-
6696b9
 Test complete.
6696b9
-- 
10e13a
2.14.4
6696b9