Skip to content

Commit d2cada8

Browse files
authored
Do not use nonces in OCSP requests
1 parent 592ccdd commit d2cada8

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/native/libs/System.Security.Cryptography.Native/opensslshim.h

-2
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,6 @@ extern bool g_libSslUses32BitTime;
485485
REQUIRED_FUNCTION(OCSP_cert_to_id) \
486486
REQUIRED_FUNCTION(OCSP_check_nonce) \
487487
REQUIRED_FUNCTION(OCSP_request_add0_id) \
488-
REQUIRED_FUNCTION(OCSP_request_add1_nonce) \
489488
REQUIRED_FUNCTION(OCSP_REQUEST_free) \
490489
REQUIRED_FUNCTION(OCSP_REQUEST_new) \
491490
REQUIRED_FUNCTION(OCSP_resp_find_status) \
@@ -1018,7 +1017,6 @@ extern TYPEOF(OPENSSL_gmtime)* OPENSSL_gmtime_ptr;
10181017
#define OCSP_check_nonce OCSP_check_nonce_ptr
10191018
#define OCSP_CERTID_free OCSP_CERTID_free_ptr
10201019
#define OCSP_request_add0_id OCSP_request_add0_id_ptr
1021-
#define OCSP_request_add1_nonce OCSP_request_add1_nonce_ptr
10221020
#define OCSP_REQUEST_free OCSP_REQUEST_free_ptr
10231021
#define OCSP_REQUEST_new OCSP_REQUEST_new_ptr
10241022
#define OCSP_resp_find_status OCSP_resp_find_status_ptr

src/native/libs/System.Security.Cryptography.Native/pal_x509.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,8 @@ static X509VerifyStatusCode CheckOcspGetExpiry(OCSP_REQUEST* req,
946946
int nonceCheck = req == NULL ? 1 : OCSP_check_nonce(req, basicResp);
947947

948948
// Treat "response has no nonce" as success, since not all responders set the nonce.
949-
if (nonceCheck == -1)
949+
// Treat "neither has a nonce" as success, since we do not send nonces in our requests.
950+
if (nonceCheck == -1 || nonceCheck == 2)
950951
{
951952
nonceCheck = 1;
952953
}
@@ -1188,8 +1189,9 @@ static OCSP_REQUEST* BuildOcspRequest(X509* subject, X509* issuer)
11881189
// Ownership was successfully transferred to req
11891190
certId = NULL;
11901191

1191-
// Add a random nonce.
1192-
OCSP_request_add1_nonce(req, NULL, -1);
1192+
// We return the request without setting a nonce on it. Most public CA OCSP responders ignore the nonce, and in some
1193+
// cases flat out error when presented with a nonce.
1194+
// This behavior also matches Windows and Apple platforms.
11931195
return req;
11941196
}
11951197

0 commit comments

Comments
 (0)