Add support for IKEv2 OCSP extensions (RFC 4806)
Closes strongswan/strongswan#2016 Co-authored-by: Tobias Brunner <[email protected]>
This commit is contained in:
committed by
Tobias Brunner
co-authored by
Tobias Brunner
parent
ddd926b698
commit
15612b3a42
@@ -90,6 +90,16 @@ struct cert_validator_t {
|
||||
bool (*validate_online)(cert_validator_t *this, certificate_t *subject,
|
||||
certificate_t *issuer, u_int pathlen, bool anchor,
|
||||
auth_cfg_t *auth);
|
||||
|
||||
/**
|
||||
* Do OCSP checking for the given certificate.
|
||||
*
|
||||
* @param subject subject certificate to check
|
||||
* @param issuer issuer of subject
|
||||
* @return a valid OCSP response, NULL otherwise
|
||||
*/
|
||||
certificate_t* (*ocsp)(cert_validator_t *this, certificate_t *subject,
|
||||
certificate_t *issuer);
|
||||
};
|
||||
|
||||
#endif /** CERT_VALIDATOR_H_ @}*/
|
||||
|
||||
@@ -1352,6 +1352,33 @@ METHOD(credential_manager_t, get_private, private_key_t*,
|
||||
return private;
|
||||
}
|
||||
|
||||
METHOD(credential_manager_t, get_ocsp, certificate_t*,
|
||||
private_credential_manager_t *this, certificate_t *subject,
|
||||
certificate_t *issuer)
|
||||
{
|
||||
cert_validator_t *validator;
|
||||
enumerator_t *enumerator;
|
||||
certificate_t *response = NULL;
|
||||
|
||||
this->lock->read_lock(this->lock);
|
||||
enumerator = this->validators->create_enumerator(this->validators);
|
||||
while (enumerator->enumerate(enumerator, &validator))
|
||||
{
|
||||
if (validator->ocsp)
|
||||
{
|
||||
response = validator->ocsp(validator, subject, issuer);
|
||||
if (response)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
this->lock->unlock(this->lock);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
METHOD(credential_manager_t, flush_cache, void,
|
||||
private_credential_manager_t *this, certificate_type_t type)
|
||||
{
|
||||
@@ -1427,6 +1454,7 @@ credential_manager_t *credential_manager_create()
|
||||
.get_cert = _get_cert,
|
||||
.get_shared = _get_shared,
|
||||
.get_private = _get_private,
|
||||
.get_ocsp = _get_ocsp,
|
||||
.create_trusted_enumerator = _create_trusted_enumerator,
|
||||
.create_public_enumerator = _create_public_enumerator,
|
||||
.flush_cache = _flush_cache,
|
||||
|
||||
@@ -149,6 +149,7 @@ struct credential_manager_t {
|
||||
certificate_t *(*get_cert)(credential_manager_t *this,
|
||||
certificate_type_t cert, key_type_t key,
|
||||
identification_t *id, bool trusted);
|
||||
|
||||
/**
|
||||
* Get the best matching shared key for two IDs.
|
||||
*
|
||||
@@ -176,6 +177,16 @@ struct credential_manager_t {
|
||||
private_key_t* (*get_private)(credential_manager_t *this, key_type_t type,
|
||||
identification_t *id, auth_cfg_t *auth);
|
||||
|
||||
/**
|
||||
* Get an OCSP response for the given certificate.
|
||||
*
|
||||
* @param subject subject certificate to check
|
||||
* @param issuer issuer of subject
|
||||
* @return a valid OCSP response, NULL otherwise
|
||||
*/
|
||||
certificate_t* (*get_ocsp)(credential_manager_t *this, certificate_t *subject,
|
||||
certificate_t *issuer);
|
||||
|
||||
/**
|
||||
* Create an enumerator over trusted certificates.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user