diff options
| author | tb <> | 2026-06-26 06:03:32 +0000 |
|---|---|---|
| committer | tb <> | 2026-06-26 06:03:32 +0000 |
| commit | eebf4d462af4e3fa6153b16d82a417e97409ad41 (patch) | |
| tree | e282538cd6c6bf05becef3cff7825cfe333efe0b | |
| parent | 73d18a4f2b3d38d316d58fba24a3267634dbba54 (diff) | |
| download | openbsd-eebf4d462af4e3fa6153b16d82a417e97409ad41.tar.gz openbsd-eebf4d462af4e3fa6153b16d82a417e97409ad41.tar.bz2 openbsd-eebf4d462af4e3fa6153b16d82a417e97409ad41.zip | |
x509_vfy: sync get_crl_sk() with BoringSSL and OpenSSL
Among CRLs with the same score prefer the one with the most recent
lastUpdate (RFC 5280 thisUpdate). This pulls in OpenSSL commits
626aa248, e032117d, 8b7c51a0 from 2016, so before the license change.
This uses the annoying ASN1_TIME_diff() API, but there is no better
way, really. Every other ASN1_TIME API will be just as awkward.
This fixes the currently failing x509_crl test cases.
ok kenjiro
| -rw-r--r-- | src/lib/libcrypto/x509/x509_vfy.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/lib/libcrypto/x509/x509_vfy.c b/src/lib/libcrypto/x509/x509_vfy.c index b8e87e8597..993d057d10 100644 --- a/src/lib/libcrypto/x509/x509_vfy.c +++ b/src/lib/libcrypto/x509/x509_vfy.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: x509_vfy.c,v 1.152 2026/06/22 19:29:41 tb Exp $ */ | 1 | /* $OpenBSD: x509_vfy.c,v 1.153 2026/06/26 06:03:32 tb Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -1074,12 +1074,24 @@ get_crl_sk(X509_STORE_CTX *ctx, X509_CRL **pcrl, X509_CRL **pdcrl, | |||
| 1074 | reasons = *preasons; | 1074 | reasons = *preasons; |
| 1075 | crl_score = get_crl_score(ctx, &crl_issuer, &reasons, crl, x); | 1075 | crl_score = get_crl_score(ctx, &crl_issuer, &reasons, crl, x); |
| 1076 | 1076 | ||
| 1077 | if (crl_score > best_score) { | 1077 | if (crl_score < best_score || crl_score == 0) |
| 1078 | best_crl = crl; | 1078 | continue; |
| 1079 | best_crl_issuer = crl_issuer; | 1079 | |
| 1080 | best_score = crl_score; | 1080 | if (crl_score == best_score && best_crl != NULL) { |
| 1081 | best_reasons = reasons; | 1081 | int day, sec; |
| 1082 | |||
| 1083 | if (!ASN1_TIME_diff(&day, &sec, best_crl->crl->lastUpdate, | ||
| 1084 | crl->crl->lastUpdate)) | ||
| 1085 | continue; | ||
| 1086 | |||
| 1087 | if (day <= 0 && sec <= 0) | ||
| 1088 | continue; | ||
| 1082 | } | 1089 | } |
| 1090 | |||
| 1091 | best_crl = crl; | ||
| 1092 | best_crl_issuer = crl_issuer; | ||
| 1093 | best_score = crl_score; | ||
| 1094 | best_reasons = reasons; | ||
| 1083 | } | 1095 | } |
| 1084 | 1096 | ||
| 1085 | if (best_crl != NULL) { | 1097 | if (best_crl != NULL) { |
