@@ -1016,14 +1016,16 @@ static int process_ocsp_response(OCSP_REQUEST *ocsp_req, OCSP_RESPONSE *ocsp_res
10161016 OCSP_BASICRESP * bs ;
10171017 OCSP_SINGLERESP * ss ;
10181018 OCSP_CERTID * certid ;
1019+ ASN1_GENERALIZEDTIME * thisupd ;
1020+ ASN1_GENERALIZEDTIME * nextupd ;
10191021 STACK_OF (X509 ) * certStack ;
10201022
10211023 r = OCSP_response_status (ocsp_resp );
10221024
10231025 if (r != OCSP_RESPONSE_STATUS_SUCCESSFUL ) {
10241026 return OCSP_STATUS_UNKNOWN ;
10251027 }
1026-
1028+
10271029 bs = OCSP_response_get1_basic (ocsp_resp );
10281030 if (OCSP_check_nonce (ocsp_req , bs ) == 0 ) {
10291031 X509_STORE_CTX_set_error (ctx , X509_V_ERR_OCSP_RESP_INVALID );
@@ -1046,15 +1048,26 @@ static int process_ocsp_response(OCSP_REQUEST *ocsp_req, OCSP_RESPONSE *ocsp_res
10461048 }
10471049
10481050 ss = OCSP_resp_get0 (bs , OCSP_resp_find (bs , certid , -1 )); /* find by serial number and get the matching response */
1049- i = OCSP_single_get0_status (ss , NULL , NULL , NULL , NULL );
1051+ i = OCSP_single_get0_status (ss , NULL , NULL , & thisupd , & nextupd );
1052+ if (OCSP_check_validity (thisupd , nextupd , OCSP_MAX_SKEW , -1 ) <= 0 ) {
1053+ X509_STORE_CTX_set_error (ctx , X509_V_ERR_OCSP_NOT_YET_VALID );
1054+ o = OCSP_STATUS_UNKNOWN ;
1055+ goto clean_certid ;
1056+ }
1057+ if (OCSP_check_validity (thisupd , nextupd , OCSP_MAX_SKEW , OCSP_MAX_SKEW ) <= 0 ) {
1058+ X509_STORE_CTX_set_error (ctx , X509_V_ERR_OCSP_HAS_EXPIRED );
1059+ o = OCSP_STATUS_UNKNOWN ;
1060+ goto clean_certid ;
1061+ }
1062+
10501063 if (i == V_OCSP_CERTSTATUS_GOOD )
10511064 o = OCSP_STATUS_OK ;
10521065 else if (i == V_OCSP_CERTSTATUS_REVOKED )
10531066 o = OCSP_STATUS_REVOKED ;
10541067 else if (i == V_OCSP_CERTSTATUS_UNKNOWN )
10551068 o = OCSP_STATUS_UNKNOWN ;
10561069
1057- /* we clean up */
1070+ clean_certid :
10581071 OCSP_CERTID_free (certid );
10591072clean_bs :
10601073 OCSP_BASICRESP_free (bs );
0 commit comments