From a51675fabe3af33cd7a942b71409f6546c3fad1d Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 10 Dec 2009 13:00:30 +0000 Subject: [PATCH] Add option --cert-extension. --- NEWS | 2 ++ doc/gpgsm.texi | 11 ++++++++++- sm/ChangeLog | 6 ++++++ sm/certchain.c | 17 ++++++++++++++++- sm/gpgsm.c | 8 +++++++- sm/gpgsm.h | 7 ++++++- 6 files changed, 47 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 53c4a88ef..d05571e54 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,8 @@ Noteworthy changes in version 2.1.x (under development) * Support DNS lookups for SRV, PKA and CERT on W32. + * New GPGSM option --ignore-cert-extension. + Noteworthy changes in version 2.0.13 (2009-09-04) ------------------------------------------------- diff --git a/doc/gpgsm.texi b/doc/gpgsm.texi index ffa325aa8..b2c290934 100644 --- a/doc/gpgsm.texi +++ b/doc/gpgsm.texi @@ -446,7 +446,16 @@ use of the chain model. The chain model is also used if an option in the @file{trustlist.txt} or an attribute of the certificate requests it. However the standard model (shell) is in that case always tried first. - +@item --ignore-cert-extension @var{oid} +@opindex ignore-cert-extension +Add @var{oid} to the list of ignored certificate extensions. The +@var{oid} is expected to be in dotted decimal form, like +@code{2.5.29.3}. This option may used more than once. Critical +flagged certificate extensions matching one of the OIDs in the list +are treated as if they are actually handled and thus the certificate +won't be rejected due to an unknown critical extension. Use this +option with care because extensions are usually flagged as critical +for a reason. @end table diff --git a/sm/ChangeLog b/sm/ChangeLog index bb2b4b37f..5ddec9ca1 100644 --- a/sm/ChangeLog +++ b/sm/ChangeLog @@ -1,3 +1,9 @@ +2009-12-10 Werner Koch + + * gpgsm.c: Add option --ignore-cert-extension. + * gpgsm.h (opt): Add field IGNORED_CERT_EXTENSIONS. + * certchain.c (unknown_criticals): Handle ignored extensions, + 2009-12-08 Werner Koch * keydb.c (keydb_search_kid): Fix code even that it is not used. diff --git a/sm/certchain.c b/sm/certchain.c index e9a1aadfa..37ac9c15d 100644 --- a/sm/certchain.c +++ b/sm/certchain.c @@ -229,6 +229,8 @@ unknown_criticals (ksba_cert_t cert, int listmode, estream_t fp) int rc = 0, i, idx, crit; const char *oid; gpg_error_t err; + int unsupported; + strlist_t sl; for (idx=0; !(err=ksba_cert_get_extension (cert, idx, &oid, &crit, NULL, NULL));idx++) @@ -237,7 +239,20 @@ unknown_criticals (ksba_cert_t cert, int listmode, estream_t fp) continue; for (i=0; known[i] && strcmp (known[i],oid); i++) ; - if (!known[i]) + unsupported = !known[i]; + + /* If this critical extension is not supoported, check the list + of to be ignored extensions to se whether we claim that it is + supported. */ + if (unsupported && opt.ignored_cert_extensions) + { + for (sl=opt.ignored_cert_extensions; + sl && strcmp (sl->d, oid); sl = sl->next) + ; + if (sl) + unsupported = 0; + } + if (unsupported) { do_list (1, listmode, fp, _("critical certificate extension %s is not supported"), diff --git a/sm/gpgsm.c b/sm/gpgsm.c index 834bcce23..94cc23dec 100644 --- a/sm/gpgsm.c +++ b/sm/gpgsm.c @@ -176,7 +176,8 @@ enum cmd_and_opt_values { oDisablePubkeyAlgo, oIgnoreTimeConflict, oNoRandomSeedFile, - oNoCommonCertsImport + oNoCommonCertsImport, + oIgnoreCertExtension }; @@ -376,6 +377,7 @@ static ARGPARSE_OPTS opts[] = { ARGPARSE_s_n (oIgnoreTimeConflict, "ignore-time-conflict", "@"), ARGPARSE_s_n (oNoRandomSeedFile, "no-random-seed-file", "@"), ARGPARSE_s_n (oNoCommonCertsImport, "no-common-certs-import", "@"), + ARGPARSE_s_s (oIgnoreCertExtension, "ignore-cert-extension", "@"), /* Command aliases. */ ARGPARSE_c (aListKeys, "list-key", "@"), @@ -1391,6 +1393,10 @@ main ( int argc, char **argv) } break; + case oIgnoreCertExtension: + add_to_strlist (&opt.ignored_cert_extensions, pargs.r.ret_str); + break; + default: pargs.err = configfp? ARGPARSE_PRINT_WARNING:ARGPARSE_PRINT_ERROR; break; diff --git a/sm/gpgsm.h b/sm/gpgsm.h index b6c9a763d..c4a261bf2 100644 --- a/sm/gpgsm.h +++ b/sm/gpgsm.h @@ -134,8 +134,13 @@ struct runtime. */ struct keyserver_spec *keyserver; -} opt; + /* A list of certificate extension OIDs which are ignored so that + one can claim that a critical extension has been handled. One + OID per string. */ + strlist_t ignored_cert_extensions; + +} opt; /* Debug values and macros. */ #define DBG_X509_VALUE 1 /* debug x.509 data reading/writing */