Skip to content

Commit d5c4e34

Browse files
committed
add issuer check and generate warning
1 parent 92d0aee commit d5c4e34

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

apps/cmp.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3173,6 +3173,7 @@ static int do_genm(OSSL_CMP_CTX *ctx)
31733173
} else if (opt_infotype == NID_id_it_crlStatusList) {
31743174
X509_CRL *oldcrl = NULL, *crl = NULL;
31753175
int res = 0;
3176+
const char *desc = "CRL from genp of type 'crls'";
31763177

31773178
if (opt_oldcrl == NULL && opt_oldcert == NULL) {
31783179
CMP_err("Missing -oldcrl and no -oldcert given for -infotype crlStatusList");
@@ -3191,10 +3192,18 @@ static int do_genm(OSSL_CMP_CTX *ctx)
31913192
if (oldcrl == NULL)
31923193
goto end_crlupd;
31933194
}
3195+
3196+
if (opt_oldcrl != NULL && opt_oldcert != NULL)
3197+
{
3198+
if (X509_NAME_cmp(X509_CRL_get_issuer(oldcrl),
3199+
X509_get_issuer_name(OSSL_CMP_CTX_get0_oldCert(ctx)))
3200+
!= 0)
3201+
CMP_warn("-oldcrl and -oldcert have different issuer");
3202+
}
3203+
31943204
if (!OSSL_CMP_get1_crlUpdate(ctx, oldcrl, &crl))
31953205
goto end_crlupd;
31963206

3197-
const char *desc = "CRL from genp of type 'crls'";
31983207
if (crl == NULL) {
31993208
CMP_info("no CRL update available");
32003209
if (!delete_file(opt_crlout, desc))

apps/lib/cmp_mock_srv.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,17 @@ static int check_client_crl(const STACK_OF(OSSL_CMP_CRLSTATUS) *crlStatusList,
426426
if (thisupd != NULL
427427
&& ASN1_TIME_compare(thisupd, X509_CRL_get0_lastUpdate(crl)) >= 0)
428428
return 0;
429+
if (gen != NULL) {
430+
GENERAL_NAME *gn = sk_GENERAL_NAME_value(gen, 0);
431+
432+
if (gn != NULL && gn->type == GEN_DIRNAME) {
433+
X509_NAME *gen_name = gn->d.dirn;
434+
435+
if (X509_NAME_cmp(gen_name, X509_CRL_get_issuer(crl)) != 0) {
436+
return 0;
437+
}
438+
}
439+
}
429440

430441
return 1;
431442
}

crypto/cmp/cmp_genm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,10 @@ int OSSL_CMP_get1_crlUpdate(OSSL_CMP_CTX *ctx, const X509_CRL *last_crl,
386386
if (!OSSL_CMP_ITAV_get0_crls(itav, &crls))
387387
goto end;
388388

389-
if (crls == NULL) /* no CRL update available */
389+
if (crls == NULL) { /* no CRL update available */
390+
res = 1;
390391
goto end;
392+
}
391393
if (sk_X509_CRL_num(crls) != 1) {
392394
ERR_raise_data(ERR_LIB_CMP, CMP_R_INVALID_GENP,
393395
"Unexpected number of CRLs in genp: %d",

test/recipes/80-test_cmp_http_data/test_commands.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,10 @@ expected,description, -section,val, -cmd,val,val2, -cacertsout,val,val2, -infoty
8989
1,genm crlStatusList with oldcert , -section,, -cmd,genm,, BLANK,,, -infotype,crlStatusList,, -oldcert, signer_only.crt,,,,, -crlout, _RESULT_DIR/test.crlout.pem
9090
1,genm crlStatusList with old crl , -section,, -cmd,genm,, BLANK,,, -infotype,crlStatusList,, -oldcrl, oldcrl.pem,,,,, -crlout, _RESULT_DIR/test.crlout.pem
9191
1,genm crlStatusList with oldcert and old crl , -section,, -cmd,genm,, BLANK,,, -infotype,crlStatusList,, -oldcert, signer_only.crt, -oldcrl, oldcrl.pem,,, -crlout, _RESULT_DIR/test.crlout.pem
92-
0,genm crlStatusList with latest crl , -section,, -cmd,genm,, BLANK,,, -infotype,crlStatusList,, -oldcrl, newcrl.pem,,,,, -crlout, _RESULT_DIR/test.crlout.pem
92+
1,genm crlStatusList with latest crl , -section,, -cmd,genm,, BLANK,,, -infotype,crlStatusList,, -oldcrl, newcrl.pem,,,,, -crlout, _RESULT_DIR/test.crlout.pem
9393
0,genm crlStatusList with -oldcert missing, -section,, -cmd,genm,, BLANK,,, -infotype,crlStatusList,, -oldcert, idontexist,,,,, -crlout, _RESULT_DIR/test.crlout.pem
9494
0,genm crlStatusList with -oldcrl missing, -section,, -cmd,genm,, BLANK,,, -infotype,crlStatusList,, -oldcrl, idontexist,,,,, -crlout, _RESULT_DIR/test.crlout.pem
95+
1,genm crlStatusList with wrong issuer, -section,, -cmd,genm,, BLANK,,, -infotype,crlStatusList,, -oldcert, server.crt,,,,, -crlout, _RESULT_DIR/test.crlout.pem
9596
,,,,,,,,,,,,,,,,,,,,,,
9697
1,profile, -section,, -cmd,cr,, -cert,signer.crt, -key,signer.p12, -keypass,pass:12345,BLANK,, -profile,profile1,BLANK,,BLANK,
9798
0,profile wrong value, -section,, -cmd,cr,, -cert,signer.crt, -key,signer.p12, -keypass,pass:12345,BLANK,, -profile,profile2,BLANK,,BLANK,

0 commit comments

Comments
 (0)