Blame SOURCES/0037-Add-new-option-to-allow-overriding-the-detected-SCEP.patch

f0b236
From 37ebf87fb6fc93d445139310a1c89b98f3f514de Mon Sep 17 00:00:00 2001
f0b236
From: Rob Crittenden <rcritten@redhat.com>
f0b236
Date: Wed, 29 Apr 2020 16:29:50 -0400
f0b236
Subject: [PATCH 37/39] Add new option to allow overriding the detected SCEP CA
f0b236
 chain
f0b236
f0b236
The -R option was doing double-duty for the SCEP CA.
f0b236
f0b236
1. It was required if the SCEP URL used TLS
f0b236
2. It override the CA certificate downloaded from the SCEP server
f0b236
f0b236
If the chains were different then validating the SCEP responses would
f0b236
fail.
f0b236
f0b236
https://bugzilla.redhat.com/show_bug.cgi?id=1808613
f0b236
---
f0b236
 src/certmonger-scep-submit.8.in | 14 +++++++++-----
f0b236
 src/getcert-add-scep-ca.1.in    | 12 ++++++++----
f0b236
 src/getcert.c                   |  6 +++++-
f0b236
 src/scep.c                      | 13 ++++++-------
f0b236
 4 files changed, 28 insertions(+), 17 deletions(-)
f0b236
f0b236
diff --git a/src/certmonger-scep-submit.8.in b/src/certmonger-scep-submit.8.in
f0b236
index 95d674a..42ffcd6 100644
f0b236
--- a/src/certmonger-scep-submit.8.in
f0b236
+++ b/src/certmonger-scep-submit.8.in
f0b236
@@ -8,6 +8,7 @@ scep-submit -u SERVER-URL
f0b236
 [-r ra-cert-file]
f0b236
 [-R ca-cert-file]
f0b236
 [-I other-certs-file]
f0b236
+[-N ca-cert-file]
f0b236
 [-i ca-identifier]
f0b236
 [-v]
f0b236
 [-n]
f0b236
@@ -57,11 +58,14 @@ typically \fIhttp://\fBSERVER\fP/cgi-bin/PKICLIENT.EXE\fR or
f0b236
 always required.
f0b236
 .TP
f0b236
 \fB\-R\fR CA-certificate-file
f0b236
-The location of the SCEP server's CA certificate, which was used to
f0b236
-issue the SCEP server's certificate, or the SCEP server's own
f0b236
-certificate, if it is self-signed, in PEM form.  If the URL specified
f0b236
-with the \fB-u\fR option is an \fIhttps\fR URL, then this option is
f0b236
-required.
f0b236
+The location of the CA certificate which was used to issue the SCEP web
f0b236
+server's certificate in PEM form. If the URL specified with the
f0b236
+\fB-u\fR option is an \fIhttps\fR URL, then this option is required.
f0b236
+.TP
f0b236
+\fB\-N\fR ca-certificate-file
f0b236
+The location of a PEM-formatted copy of the SCEP server's CA certificate.
f0b236
+A discovered value is normally supplied by the certmonger daemon, but one can
f0b236
+be specified for troubleshooting purposes.
f0b236
 .TP
f0b236
 \fB\-r\fR RA-certificate-file
f0b236
 The location of the SCEP server's RA certificate, which is expected to
f0b236
diff --git a/src/getcert-add-scep-ca.1.in b/src/getcert-add-scep-ca.1.in
f0b236
index 11ab4ce..bf07306 100644
f0b236
--- a/src/getcert-add-scep-ca.1.in
f0b236
+++ b/src/getcert-add-scep-ca.1.in
f0b236
@@ -24,12 +24,16 @@ The location of the SCEP server's enrollment interface.  This option must be
f0b236
 specified.
f0b236
 .TP
f0b236
 \fB\-R\fR ca-certificate-file
f0b236
-The location of a PEM-formatted copy of the SCEP server's CA's certificate.
f0b236
-A discovered value is supplied by the certmonger daemon for use in verifying
f0b236
-the signature on data returned by the SCEP server, but it is not used for
f0b236
-verifying HTTPS server certificates.
f0b236
+The location of a PEM-formatted copy of the CA's certificate used to verify
f0b236
+the TLS connection the SCEP server.
f0b236
+
f0b236
 This option must be specified if the URL is an \fIhttps\fR location.
f0b236
 .TP
f0b236
+\fB\-N\fR ca-certificate-file
f0b236
+The location of a PEM-formatted copy of the SCEP server's CA certificate.
f0b236
+A discovered value is normally supplied by the certmonger daemon, but one can
f0b236
+be specified for troubleshooting purposes.
f0b236
+.TP
f0b236
 \fB\-r\fR ra-certificate-file
f0b236
 The location of a PEM-formatted copy of the SCEP server's RA's certificate.
f0b236
 A discovered value is normally supplied by the certmonger daemon, but one can
f0b236
diff --git a/src/getcert.c b/src/getcert.c
f0b236
index 3d78a73..493771f 100644
f0b236
--- a/src/getcert.c
f0b236
+++ b/src/getcert.c
f0b236
@@ -4496,6 +4496,7 @@ add_scep_ca(const char *argv0, int argc, const char **argv)
f0b236
 	enum cm_tdbus_type bus = CM_DBUS_DEFAULT_BUS;
f0b236
 	char *caname = NULL, *url = NULL, *path = NULL, *id = NULL;
f0b236
 	char *root = NULL, *racert = NULL, *certs = NULL, *nickname, *command;
f0b236
+	char *signingca = NULL;
f0b236
 	const char *err;
f0b236
 	int c, prefer_non_renewal = 0, verbose = 0;
f0b236
 	dbus_bool_t b;
f0b236
@@ -4508,6 +4509,7 @@ add_scep_ca(const char *argv0, int argc, const char **argv)
f0b236
 		{"ca-cert", 'R', POPT_ARG_STRING, &root, 0, _("file containing CA's certificate"), HELP_TYPE_FILENAME},
f0b236
 		{"ra-cert", 'r', POPT_ARG_STRING, &racert, 0, _("file containing RA's certificate"), HELP_TYPE_FILENAME},
f0b236
 		{"other-certs", 'I', POPT_ARG_STRING, &certs, 0, _("file containing certificates in RA's certifying chain"), HELP_TYPE_FILENAME},
f0b236
+		{"signingca", 'N', POPT_ARG_STRING, NULL, &signingca, 0, _("the CA certificate which signed the RA certificate"), HELP_TYPE_FILENAME},
f0b236
 		{"non-renewal", 'n', POPT_ARG_NONE, &prefer_non_renewal, 0, _("prefer to not use the SCEP Renewal feature"), NULL},
f0b236
 		{"session", 's', POPT_ARG_NONE, NULL, 's', _("connect to the certmonger service on the session bus"), NULL},
f0b236
 		{"system", 'S', POPT_ARG_NONE, NULL, 'S', _("connect to the certmonger service on the system bus"), NULL},
f0b236
@@ -4569,7 +4571,7 @@ add_scep_ca(const char *argv0, int argc, const char **argv)
f0b236
 		return 1;
f0b236
 	}
f0b236
 	command = talloc_asprintf(globals.tctx,
f0b236
-				  "%s -u %s %s %s %s %s %s %s %s",
f0b236
+				  "%s -u %s %s %s %s %s %s %s %s %s %s",
f0b236
 				  shell_escape(globals.tctx,
f0b236
 					       CM_SCEP_HELPER_PATH),
f0b236
 				  shell_escape(globals.tctx, url),
f0b236
@@ -4579,6 +4581,8 @@ add_scep_ca(const char *argv0, int argc, const char **argv)
f0b236
 				  racert ? shell_escape(globals.tctx, racert) : "",
f0b236
 				  certs ? "-I" : "",
f0b236
 				  certs ? shell_escape(globals.tctx, certs) : "",
f0b236
+				  signingca ? "-N" : "",
f0b236
+				  signingca ? shell_escape(globals.tctx, signingca) : "",
f0b236
 				  prefer_non_renewal ? "-n" : "");
f0b236
 	for (c = 0; c < verbose; c++) {
f0b236
 		command = talloc_strdup_append(command, " -v");
f0b236
diff --git a/src/scep.c b/src/scep.c
f0b236
index b80278e..4294cda 100644
f0b236
--- a/src/scep.c
f0b236
+++ b/src/scep.c
f0b236
@@ -206,7 +206,6 @@ main(int argc, const char **argv)
f0b236
 	enum known_ops op = op_unset;
f0b236
 	const char *id = NULL;
f0b236
 	char *cainfo = NULL;
f0b236
-	char *poptarg;
f0b236
 	char *message = NULL, *rekey_message = NULL;
f0b236
 	const char *mode = NULL, *content_type = NULL, *content_type2 = NULL;
f0b236
 	void *ctx;
f0b236
@@ -235,8 +234,9 @@ main(int argc, const char **argv)
f0b236
 		{"get-initial-cert", 'g', POPT_ARG_NONE, NULL, 'g', "send a PKIOperation pkiMessage", NULL},
f0b236
 		{"pki-message", 'p', POPT_ARG_NONE, NULL, 'p', "send a PKIOperation pkiMessage", NULL},
f0b236
 		{"racert", 'r', POPT_ARG_STRING, NULL, 'r', "the RA certificate, used for encrypting requests", "FILENAME"},
f0b236
-		{"cacert", 'R', POPT_ARG_STRING, NULL, 'R', "the CA certificate, used for verifying responses", "FILENAME"},
f0b236
+		{"cacert", 'R', POPT_ARG_STRING, NULL, 'R', "the CA certificate, used for verifying TLS connections", "FILENAME"},
f0b236
 		{"other-certs", 'I', POPT_ARG_STRING, NULL, 'I', "additional certificates", "FILENAME"},
f0b236
+		{"signingca", 'N', POPT_ARG_STRING, NULL, 'N', "the CA certificate which signed the RA certificate", "FILENAME"},
f0b236
 		{"non-renewal", 'n', POPT_ARG_NONE, &prefer_non_renewal, 0, "prefer to not use the SCEP Renewal feature", NULL},
f0b236
 		{"verbose", 'v', POPT_ARG_NONE, NULL, 'v', NULL, NULL},
f0b236
 		POPT_AUTOHELP
f0b236
@@ -329,9 +329,10 @@ main(int argc, const char **argv)
f0b236
 			racert = cm_submit_u_from_file(poptGetOptArg(pctx));
f0b236
 			break;
f0b236
 		case 'R':
f0b236
-			poptarg = poptGetOptArg(pctx);
f0b236
-			cainfo = strdup(poptarg);
f0b236
-			cacert = cm_submit_u_from_file(poptarg);
f0b236
+			cainfo = poptGetOptArg(pctx);
f0b236
+			break;
f0b236
+		case 'N':
f0b236
+			cacert = cm_submit_u_from_file(poptGetOptArg(pctx));
f0b236
 			break;
f0b236
 		case 'I':
f0b236
 			certs = cm_submit_u_from_file(poptGetOptArg(pctx));
f0b236
@@ -340,7 +341,6 @@ main(int argc, const char **argv)
f0b236
 	}
f0b236
 	if (c != -1) {
f0b236
 		poptPrintUsage(pctx, stdout, 0);
f0b236
-		free(cainfo);
f0b236
 		return CM_SUBMIT_STATUS_UNCONFIGURED;
f0b236
 	}
f0b236
 
f0b236
@@ -1189,7 +1189,6 @@ done:
f0b236
 	if (pctx) {
f0b236
 		poptFreeContext(pctx);
f0b236
 	}
f0b236
-	free(cainfo);
f0b236
 	free(id);
f0b236
 	cm_submit_h_cleanup(hctx);
f0b236
 	talloc_free(ctx);
f0b236
-- 
f0b236
2.21.1
f0b236