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

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