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