|
|
71e593 |
From 1a8969bb1b3dbd1d5ef7f29dd0fa2ddc8a50fa8b Mon Sep 17 00:00:00 2001
|
|
|
71e593 |
From: Sumit Bose <sbose@redhat.com>
|
|
|
71e593 |
Date: Thu, 11 Oct 2018 17:35:24 +0200
|
|
|
71e593 |
Subject: [PATCH 52/57] p11_child: add crl_file option for the OpenSSL build
|
|
|
71e593 |
|
|
|
71e593 |
In the NSS build a Certificate Revocation List (CRL) can just be added
|
|
|
71e593 |
to the NSS database. For OpenSSL a separate file is needed.
|
|
|
71e593 |
|
|
|
71e593 |
Related to https://pagure.io/SSSD/sssd/issue/3489
|
|
|
71e593 |
|
|
|
71e593 |
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
71e593 |
(cherry picked from commit 3c096c9ad6dad911d035cfdd802b5dda4710fc68)
|
|
|
71e593 |
---
|
|
|
71e593 |
src/man/sssd.conf.5.xml | 24 ++++++++++++++++++++++++
|
|
|
71e593 |
src/p11_child/p11_child_common.c | 12 ++++++------
|
|
|
71e593 |
src/p11_child/p11_child_openssl.c | 26 +++++++++++++++++++++++++-
|
|
|
71e593 |
src/tests/cmocka/test_utils.c | 16 ++++++++++++++++
|
|
|
71e593 |
src/util/util.c | 13 +++++++++++++
|
|
|
71e593 |
src/util/util.h | 1 +
|
|
|
71e593 |
6 files changed, 85 insertions(+), 7 deletions(-)
|
|
|
71e593 |
|
|
|
71e593 |
diff --git a/src/man/sssd.conf.5.xml b/src/man/sssd.conf.5.xml
|
|
|
71e593 |
index 5e3ae48d04cc38ea54547a63c6c31795e12544c2..bea25c62286fa638bec47cb7404341be6190f410 100644
|
|
|
71e593 |
--- a/src/man/sssd.conf.5.xml
|
|
|
71e593 |
+++ b/src/man/sssd.conf.5.xml
|
|
|
71e593 |
@@ -503,6 +503,30 @@
|
|
|
71e593 |
pam_cert_db_path.</para>
|
|
|
71e593 |
</listitem>
|
|
|
71e593 |
</varlistentry>
|
|
|
71e593 |
+ <varlistentry>
|
|
|
71e593 |
+ <term>crl_file=/PATH/TO/CRL/FILE</term>
|
|
|
71e593 |
+ <listitem>
|
|
|
71e593 |
+ <para>(NSS Version) This option is
|
|
|
71e593 |
+ ignored, please see
|
|
|
71e593 |
+ <citerefentry>
|
|
|
71e593 |
+ <refentrytitle>crlutil</refentrytitle>
|
|
|
71e593 |
+ <manvolnum>1</manvolnum>
|
|
|
71e593 |
+ </citerefentry>
|
|
|
71e593 |
+ how to import a Certificate Revocation
|
|
|
71e593 |
+ List (CRL) into a NSS database.</para>
|
|
|
71e593 |
+
|
|
|
71e593 |
+ <para>(OpenSSL Version) Use the
|
|
|
71e593 |
+ Certificate Revocation List (CRL) from
|
|
|
71e593 |
+ the given file during the verification
|
|
|
71e593 |
+ of the certificate. The CRL must be
|
|
|
71e593 |
+ given in PEM format, see
|
|
|
71e593 |
+ <citerefentry>
|
|
|
71e593 |
+ <refentrytitle>crl</refentrytitle>
|
|
|
71e593 |
+ <manvolnum>1ssl</manvolnum>
|
|
|
71e593 |
+ </citerefentry>
|
|
|
71e593 |
+ for details.</para>
|
|
|
71e593 |
+ </listitem>
|
|
|
71e593 |
+ </varlistentry>
|
|
|
71e593 |
</variablelist>
|
|
|
71e593 |
</para>
|
|
|
71e593 |
<para condition="with_nss">
|
|
|
71e593 |
diff --git a/src/p11_child/p11_child_common.c b/src/p11_child/p11_child_common.c
|
|
|
71e593 |
index 097e7fa07fb4d90e087250aec9f971b4a2afdb52..b992aeb71ee6c8acc8792265aaa7bdcf0d06770d 100644
|
|
|
71e593 |
--- a/src/p11_child/p11_child_common.c
|
|
|
71e593 |
+++ b/src/p11_child/p11_child_common.c
|
|
|
71e593 |
@@ -48,7 +48,7 @@ static const char *op_mode_str(enum op_mode mode)
|
|
|
71e593 |
return "pre-auth";
|
|
|
71e593 |
break;
|
|
|
71e593 |
case OP_VERIFIY:
|
|
|
71e593 |
- return "verifiy";
|
|
|
71e593 |
+ return "verify";
|
|
|
71e593 |
break;
|
|
|
71e593 |
default:
|
|
|
71e593 |
return "unknown";
|
|
|
71e593 |
@@ -219,7 +219,7 @@ int main(int argc, const char *argv[])
|
|
|
71e593 |
case 'a':
|
|
|
71e593 |
if (mode != OP_NONE) {
|
|
|
71e593 |
fprintf(stderr,
|
|
|
71e593 |
- "\n--verifiy, --auth and --pre are mutually " \
|
|
|
71e593 |
+ "\n--verify, --auth and --pre are mutually " \
|
|
|
71e593 |
"exclusive and should be only used once.\n\n");
|
|
|
71e593 |
poptPrintUsage(pc, stderr, 0);
|
|
|
71e593 |
_exit(-1);
|
|
|
71e593 |
@@ -229,7 +229,7 @@ int main(int argc, const char *argv[])
|
|
|
71e593 |
case 'p':
|
|
|
71e593 |
if (mode != OP_NONE) {
|
|
|
71e593 |
fprintf(stderr,
|
|
|
71e593 |
- "\n--verifiy, --auth and --pre are mutually " \
|
|
|
71e593 |
+ "\n--verify, --auth and --pre are mutually " \
|
|
|
71e593 |
"exclusive and should be only used once.\n\n");
|
|
|
71e593 |
poptPrintUsage(pc, stderr, 0);
|
|
|
71e593 |
_exit(-1);
|
|
|
71e593 |
@@ -239,7 +239,7 @@ int main(int argc, const char *argv[])
|
|
|
71e593 |
case 'v':
|
|
|
71e593 |
if (mode != OP_NONE) {
|
|
|
71e593 |
fprintf(stderr,
|
|
|
71e593 |
- "\n--verifiy, --auth and --pre are mutually " \
|
|
|
71e593 |
+ "\n--verify, --auth and --pre are mutually " \
|
|
|
71e593 |
"exclusive and should be only used once.\n\n");
|
|
|
71e593 |
poptPrintUsage(pc, stderr, 0);
|
|
|
71e593 |
_exit(-1);
|
|
|
71e593 |
@@ -283,7 +283,7 @@ int main(int argc, const char *argv[])
|
|
|
71e593 |
|
|
|
71e593 |
if (mode == OP_NONE) {
|
|
|
71e593 |
fprintf(stderr, "\nMissing operation mode, either " \
|
|
|
71e593 |
- "--verifiy, --auth or --pre must be specified.\n\n");
|
|
|
71e593 |
+ "--verify, --auth or --pre must be specified.\n\n");
|
|
|
71e593 |
poptPrintUsage(pc, stderr, 0);
|
|
|
71e593 |
_exit(-1);
|
|
|
71e593 |
} else if (mode == OP_AUTH && pin_mode == PIN_NONE) {
|
|
|
71e593 |
@@ -350,7 +350,7 @@ int main(int argc, const char *argv[])
|
|
|
71e593 |
|
|
|
71e593 |
ret = parse_cert_verify_opts(main_ctx, verify_opts, &cert_verify_opts);
|
|
|
71e593 |
if (ret != EOK) {
|
|
|
71e593 |
- DEBUG(SSSDBG_FATAL_FAILURE, "Failed to parse verifiy option.\n");
|
|
|
71e593 |
+ DEBUG(SSSDBG_FATAL_FAILURE, "Failed to parse verify option.\n");
|
|
|
71e593 |
goto fail;
|
|
|
71e593 |
}
|
|
|
71e593 |
|
|
|
71e593 |
diff --git a/src/p11_child/p11_child_openssl.c b/src/p11_child/p11_child_openssl.c
|
|
|
71e593 |
index d66a2f82becfa24eae867a2f3df3e23263a5273c..9defdfc5a7acc70d0cea06d4919b06b93eb33c7b 100644
|
|
|
71e593 |
--- a/src/p11_child/p11_child_openssl.c
|
|
|
71e593 |
+++ b/src/p11_child/p11_child_openssl.c
|
|
|
71e593 |
@@ -501,6 +501,7 @@ errno_t init_verification(struct p11_ctx *p11_ctx,
|
|
|
71e593 |
X509_STORE *store = NULL;
|
|
|
71e593 |
unsigned long err;
|
|
|
71e593 |
X509_LOOKUP *lookup = NULL;
|
|
|
71e593 |
+ X509_VERIFY_PARAM *verify_param = NULL;
|
|
|
71e593 |
|
|
|
71e593 |
store = X509_STORE_new();
|
|
|
71e593 |
if (store == NULL) {
|
|
|
71e593 |
@@ -527,6 +528,30 @@ errno_t init_verification(struct p11_ctx *p11_ctx,
|
|
|
71e593 |
goto done;
|
|
|
71e593 |
}
|
|
|
71e593 |
|
|
|
71e593 |
+ if (cert_verify_opts->crl_file != NULL) {
|
|
|
71e593 |
+ verify_param = X509_VERIFY_PARAM_new();
|
|
|
71e593 |
+ if (verify_param == NULL) {
|
|
|
71e593 |
+ DEBUG(SSSDBG_OP_FAILURE, "X509_VERIFY_PARAM_new failed.\n");
|
|
|
71e593 |
+ ret = ENOMEM;
|
|
|
71e593 |
+ goto done;
|
|
|
71e593 |
+ }
|
|
|
71e593 |
+
|
|
|
71e593 |
+ X509_VERIFY_PARAM_set_flags(verify_param, (X509_V_FLAG_CRL_CHECK
|
|
|
71e593 |
+ | X509_V_FLAG_CRL_CHECK_ALL));
|
|
|
71e593 |
+
|
|
|
71e593 |
+ X509_STORE_set1_param(store, verify_param);
|
|
|
71e593 |
+
|
|
|
71e593 |
+ ret = X509_load_crl_file(lookup, cert_verify_opts->crl_file,
|
|
|
71e593 |
+ X509_FILETYPE_PEM);
|
|
|
71e593 |
+ if (ret == 0) {
|
|
|
71e593 |
+ err = ERR_get_error();
|
|
|
71e593 |
+ DEBUG(SSSDBG_OP_FAILURE, "X509_load_crl_file failed [%lu][%s].\n",
|
|
|
71e593 |
+ err, ERR_error_string(err, NULL));
|
|
|
71e593 |
+ ret = EIO;
|
|
|
71e593 |
+ goto done;
|
|
|
71e593 |
+ }
|
|
|
71e593 |
+ }
|
|
|
71e593 |
+
|
|
|
71e593 |
p11_ctx->x509_store = store;
|
|
|
71e593 |
p11_ctx->cert_verify_opts = cert_verify_opts;
|
|
|
71e593 |
talloc_set_destructor(p11_ctx, talloc_free_x509_store);
|
|
|
71e593 |
@@ -536,7 +561,6 @@ errno_t init_verification(struct p11_ctx *p11_ctx,
|
|
|
71e593 |
done:
|
|
|
71e593 |
if (ret != EOK) {
|
|
|
71e593 |
X509_STORE_free(store);
|
|
|
71e593 |
- X509_LOOKUP_free(lookup);
|
|
|
71e593 |
}
|
|
|
71e593 |
|
|
|
71e593 |
return ret;
|
|
|
71e593 |
diff --git a/src/tests/cmocka/test_utils.c b/src/tests/cmocka/test_utils.c
|
|
|
71e593 |
index c86e526e8299122c1c613c8459d3df0d9e4fc878..cf1c2ae6787cd1b011089b57d6bac320dadd60de 100644
|
|
|
71e593 |
--- a/src/tests/cmocka/test_utils.c
|
|
|
71e593 |
+++ b/src/tests/cmocka/test_utils.c
|
|
|
71e593 |
@@ -1567,6 +1567,7 @@ static void test_parse_cert_verify_opts(void **state)
|
|
|
71e593 |
assert_true(cv_opts->do_ocsp);
|
|
|
71e593 |
assert_null(cv_opts->ocsp_default_responder);
|
|
|
71e593 |
assert_null(cv_opts->ocsp_default_responder_signing_cert);
|
|
|
71e593 |
+ assert_null(cv_opts->crl_file);
|
|
|
71e593 |
talloc_free(cv_opts);
|
|
|
71e593 |
|
|
|
71e593 |
ret = parse_cert_verify_opts(global_talloc_context, "wedfkwefjk", &cv_opts);
|
|
|
71e593 |
@@ -1575,6 +1576,7 @@ static void test_parse_cert_verify_opts(void **state)
|
|
|
71e593 |
assert_true(cv_opts->do_ocsp);
|
|
|
71e593 |
assert_null(cv_opts->ocsp_default_responder);
|
|
|
71e593 |
assert_null(cv_opts->ocsp_default_responder_signing_cert);
|
|
|
71e593 |
+ assert_null(cv_opts->crl_file);
|
|
|
71e593 |
talloc_free(cv_opts);
|
|
|
71e593 |
|
|
|
71e593 |
ret = parse_cert_verify_opts(global_talloc_context, "no_ocsp", &cv_opts);
|
|
|
71e593 |
@@ -1583,6 +1585,7 @@ static void test_parse_cert_verify_opts(void **state)
|
|
|
71e593 |
assert_false(cv_opts->do_ocsp);
|
|
|
71e593 |
assert_null(cv_opts->ocsp_default_responder);
|
|
|
71e593 |
assert_null(cv_opts->ocsp_default_responder_signing_cert);
|
|
|
71e593 |
+ assert_null(cv_opts->crl_file);
|
|
|
71e593 |
talloc_free(cv_opts);
|
|
|
71e593 |
|
|
|
71e593 |
ret = parse_cert_verify_opts(global_talloc_context, "no_verification",
|
|
|
71e593 |
@@ -1592,6 +1595,7 @@ static void test_parse_cert_verify_opts(void **state)
|
|
|
71e593 |
assert_true(cv_opts->do_ocsp);
|
|
|
71e593 |
assert_null(cv_opts->ocsp_default_responder);
|
|
|
71e593 |
assert_null(cv_opts->ocsp_default_responder_signing_cert);
|
|
|
71e593 |
+ assert_null(cv_opts->crl_file);
|
|
|
71e593 |
talloc_free(cv_opts);
|
|
|
71e593 |
|
|
|
71e593 |
ret = parse_cert_verify_opts(global_talloc_context,
|
|
|
71e593 |
@@ -1601,6 +1605,7 @@ static void test_parse_cert_verify_opts(void **state)
|
|
|
71e593 |
assert_false(cv_opts->do_ocsp);
|
|
|
71e593 |
assert_null(cv_opts->ocsp_default_responder);
|
|
|
71e593 |
assert_null(cv_opts->ocsp_default_responder_signing_cert);
|
|
|
71e593 |
+ assert_null(cv_opts->crl_file);
|
|
|
71e593 |
talloc_free(cv_opts);
|
|
|
71e593 |
|
|
|
71e593 |
ret = parse_cert_verify_opts(global_talloc_context,
|
|
|
71e593 |
@@ -1633,6 +1638,17 @@ static void test_parse_cert_verify_opts(void **state)
|
|
|
71e593 |
assert_true(cv_opts->do_ocsp);
|
|
|
71e593 |
assert_string_equal(cv_opts->ocsp_default_responder, "abc");
|
|
|
71e593 |
assert_string_equal(cv_opts->ocsp_default_responder_signing_cert, "def");
|
|
|
71e593 |
+ assert_null(cv_opts->crl_file);
|
|
|
71e593 |
+ talloc_free(cv_opts);
|
|
|
71e593 |
+
|
|
|
71e593 |
+ ret = parse_cert_verify_opts(global_talloc_context, "crl_file=hij",
|
|
|
71e593 |
+ &cv_opts);
|
|
|
71e593 |
+ assert_int_equal(ret, EOK);
|
|
|
71e593 |
+ assert_true(cv_opts->do_verification);
|
|
|
71e593 |
+ assert_true(cv_opts->do_ocsp);
|
|
|
71e593 |
+ assert_null(cv_opts->ocsp_default_responder);
|
|
|
71e593 |
+ assert_null(cv_opts->ocsp_default_responder_signing_cert);
|
|
|
71e593 |
+ assert_string_equal(cv_opts->crl_file, "hij");
|
|
|
71e593 |
talloc_free(cv_opts);
|
|
|
71e593 |
}
|
|
|
71e593 |
|
|
|
71e593 |
diff --git a/src/util/util.c b/src/util/util.c
|
|
|
71e593 |
index 7f475fa9b5f5ddd69e80d5639380824cef82562c..cbe6a2870c302c51770ef5b526bd5bf8cc8df0e0 100644
|
|
|
71e593 |
--- a/src/util/util.c
|
|
|
71e593 |
+++ b/src/util/util.c
|
|
|
71e593 |
@@ -1024,6 +1024,7 @@ static struct cert_verify_opts *init_cert_verify_opts(TALLOC_CTX *mem_ctx)
|
|
|
71e593 |
cert_verify_opts->do_verification = true;
|
|
|
71e593 |
cert_verify_opts->ocsp_default_responder = NULL;
|
|
|
71e593 |
cert_verify_opts->ocsp_default_responder_signing_cert = NULL;
|
|
|
71e593 |
+ cert_verify_opts->crl_file = NULL;
|
|
|
71e593 |
|
|
|
71e593 |
return cert_verify_opts;
|
|
|
71e593 |
}
|
|
|
71e593 |
@@ -1035,6 +1036,8 @@ static struct cert_verify_opts *init_cert_verify_opts(TALLOC_CTX *mem_ctx)
|
|
|
71e593 |
"ocsp_default_responder_signing_cert="
|
|
|
71e593 |
#define OCSP_DEFAUL_RESPONDER_SIGNING_CERT_LEN \
|
|
|
71e593 |
(sizeof(OCSP_DEFAUL_RESPONDER_SIGNING_CERT) - 1)
|
|
|
71e593 |
+#define CRL_FILE "crl_file="
|
|
|
71e593 |
+#define CRL_FILE_LEN (sizeof(CRL_FILE) -1)
|
|
|
71e593 |
|
|
|
71e593 |
errno_t parse_cert_verify_opts(TALLOC_CTX *mem_ctx, const char *verify_opts,
|
|
|
71e593 |
struct cert_verify_opts **_cert_verify_opts)
|
|
|
71e593 |
@@ -1116,6 +1119,16 @@ errno_t parse_cert_verify_opts(TALLOC_CTX *mem_ctx, const char *verify_opts,
|
|
|
71e593 |
DEBUG(SSSDBG_TRACE_ALL,
|
|
|
71e593 |
"Using OCSP default responder signing cert nickname [%s]\n",
|
|
|
71e593 |
cert_verify_opts->ocsp_default_responder_signing_cert);
|
|
|
71e593 |
+ } else if (strncasecmp(opts[c], CRL_FILE, CRL_FILE_LEN) == 0) {
|
|
|
71e593 |
+ cert_verify_opts->crl_file = talloc_strdup(cert_verify_opts,
|
|
|
71e593 |
+ &opts[c][CRL_FILE_LEN]);
|
|
|
71e593 |
+ if (cert_verify_opts->crl_file == NULL
|
|
|
71e593 |
+ || *cert_verify_opts->crl_file == '\0') {
|
|
|
71e593 |
+ DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
71e593 |
+ "Failed to parse crl_file option [%s].\n", opts[c]);
|
|
|
71e593 |
+ ret = EINVAL;
|
|
|
71e593 |
+ goto done;
|
|
|
71e593 |
+ }
|
|
|
71e593 |
} else {
|
|
|
71e593 |
DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
71e593 |
"Unsupported certificate verification option [%s], " \
|
|
|
71e593 |
diff --git a/src/util/util.h b/src/util/util.h
|
|
|
71e593 |
index e3e91009728cd8a5a92701220c06e8c378f47431..7e9b3d6a6fe323606ab9646b9757e725b5a4ef74 100644
|
|
|
71e593 |
--- a/src/util/util.h
|
|
|
71e593 |
+++ b/src/util/util.h
|
|
|
71e593 |
@@ -371,6 +371,7 @@ struct cert_verify_opts {
|
|
|
71e593 |
bool do_verification;
|
|
|
71e593 |
char *ocsp_default_responder;
|
|
|
71e593 |
char *ocsp_default_responder_signing_cert;
|
|
|
71e593 |
+ char *crl_file;
|
|
|
71e593 |
};
|
|
|
71e593 |
|
|
|
71e593 |
errno_t parse_cert_verify_opts(TALLOC_CTX *mem_ctx, const char *verify_opts,
|
|
|
71e593 |
--
|
|
|
71e593 |
2.14.4
|
|
|
71e593 |
|