Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for RFC6960's id-pkix-ocsp-extended-revoke #3

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/libpki/pki_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ PKI_TIME *PKI_TIME_new( long long offset );
void PKI_TIME_free_void( void *time );
int PKI_TIME_free( PKI_TIME *time );

PKI_TIME *PKI_TIME_set(PKI_TIME *time, time_t new_time);
int PKI_TIME_adj( PKI_TIME *time, long long offset );

PKI_TIME * PKI_TIME_dup ( PKI_TIME *time );
Expand Down
21 changes: 20 additions & 1 deletion src/openssl/pki_ocsp_resp.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ int PKI_X509_OCSP_RESP_add ( PKI_X509_OCSP_RESP *resp,

OCSP_SINGLERESP *single = NULL;
PKI_TIME *myThisUpdate = NULL;

X509_EXTENSION *extendedRevocation = NULL;
PKI_OCSP_RESP *r = NULL;

if ( !resp || !resp->value || !cid ) return ( PKI_ERR );
Expand Down Expand Up @@ -204,6 +204,25 @@ int PKI_X509_OCSP_RESP_add ( PKI_X509_OCSP_RESP *resp,
}
}

if ((extendedRevocation = X509_EXTENSION_new()) == NULL)
{
PKI_log_err("Can't allocate memory for extended revocation extension.");
//ERR_print_errors_fp(stdout);
return PKI_ERR;
}
//As per RFC6960 set critical to 0 and the OID to id-pkix-ocsp-extended-revoke and value to NULL
//We specify NID_id_pkix_OCSP_valid due to an error in OpenSSL's code, see http://marc.info/?l=openssl-users&m=138573884214852&w=2
extendedRevocation->critical = 0;
extendedRevocation->object = OBJ_nid2obj(NID_id_pkix_OCSP_valid);
extendedRevocation->value = ASN1_OCTET_STRING_new();
//This extension goes to responseExtensions and not singleExtensions like invalidityDate
if (!OCSP_BASICRESP_add_ext(r->bs, extendedRevocation, -1))
{
PKI_log_err("Can not create \"id-pkix-ocsp-extended-revoke\" extension entry for response!");
//ERR_print_errors_fp(stdout);
return PKI_ERR;
}

return PKI_OK;
}

Expand Down
13 changes: 13 additions & 0 deletions src/openssl/pki_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ int PKI_TIME_free( PKI_TIME *time ) {
return (PKI_OK);
}

/*!
* \brief Sets the passed PKI_TIME to the provided time_t
*/

PKI_TIME *PKI_TIME_set(PKI_TIME *time, time_t new_time) {

if (!time) {
return NULL;
}

return ASN1_GENERALIZEDTIME_adj(time, new_time, 0, 0);
}

/*!
* \brief Adjusts the time by adding/subtracting the offset seconds from current value
*/
Expand Down