added support of OCSP accessLocations
This commit is contained in:
@@ -136,6 +136,11 @@ struct private_x509_t {
|
|||||||
*/
|
*/
|
||||||
linked_list_t *crlDistributionPoints;
|
linked_list_t *crlDistributionPoints;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of identification_t's representing ocspAccessLocations
|
||||||
|
*/
|
||||||
|
linked_list_t *ocspAccessLocations;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subject RSA public key, if subjectPublicKeyAlgorithm == RSA
|
* Subject RSA public key, if subjectPublicKeyAlgorithm == RSA
|
||||||
*/
|
*/
|
||||||
@@ -174,7 +179,6 @@ struct private_x509_t {
|
|||||||
u_char authority_flags;
|
u_char authority_flags;
|
||||||
chunk_t subjectPublicKey;
|
chunk_t subjectPublicKey;
|
||||||
bool isOcspSigner; /* ocsp */
|
bool isOcspSigner; /* ocsp */
|
||||||
chunk_t accessLocation; /* ocsp */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -638,7 +642,7 @@ void parse_authorityKeyIdentifier(chunk_t blob, int level0 , chunk_t *authKeyID,
|
|||||||
/**
|
/**
|
||||||
* extracts an authorityInfoAcess location
|
* extracts an authorityInfoAcess location
|
||||||
*/
|
*/
|
||||||
static void parse_authorityInfoAccess(chunk_t blob, int level0, chunk_t *accessLocation)
|
static void parse_authorityInfoAccess(chunk_t blob, int level0, linked_list_t *list)
|
||||||
{
|
{
|
||||||
asn1_ctx_t ctx;
|
asn1_ctx_t ctx;
|
||||||
chunk_t object;
|
chunk_t object;
|
||||||
@@ -666,17 +670,14 @@ static void parse_authorityInfoAccess(chunk_t blob, int level0, chunk_t *accessL
|
|||||||
case OID_OCSP:
|
case OID_OCSP:
|
||||||
if (*object.ptr == ASN1_CONTEXT_S_6)
|
if (*object.ptr == ASN1_CONTEXT_S_6)
|
||||||
{
|
{
|
||||||
|
identification_t *accessLocation;
|
||||||
|
|
||||||
if (asn1_length(&object) == ASN1_INVALID_LENGTH)
|
if (asn1_length(&object) == ASN1_INVALID_LENGTH)
|
||||||
return;
|
return;
|
||||||
DBG2(" '%.*s'",(int)object.len, object.ptr);
|
DBG2(" '%.*s'",(int)object.len, object.ptr);
|
||||||
/* only HTTP(S) URIs accepted */
|
accessLocation = identification_create_from_encoding(ID_DER_ASN1_GN_URI, object);
|
||||||
if (strncasecmp(object.ptr, "http", 4) == 0)
|
list->insert_last(list, (void *)accessLocation);
|
||||||
{
|
|
||||||
*accessLocation = object;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
DBG2("ignoring OCSP InfoAccessLocation with unkown protocol");
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* unkown accessMethod, ignoring */
|
/* unkown accessMethod, ignoring */
|
||||||
@@ -847,7 +848,7 @@ bool parse_x509cert(chunk_t blob, u_int level0, private_x509_t *cert)
|
|||||||
parse_authorityKeyIdentifier(object, level , &cert->authKeyID, &cert->authKeySerialNumber);
|
parse_authorityKeyIdentifier(object, level , &cert->authKeyID, &cert->authKeySerialNumber);
|
||||||
break;
|
break;
|
||||||
case OID_AUTHORITY_INFO_ACCESS:
|
case OID_AUTHORITY_INFO_ACCESS:
|
||||||
parse_authorityInfoAccess(object, level, &cert->accessLocation);
|
parse_authorityInfoAccess(object, level, cert->ocspAccessLocations);
|
||||||
break;
|
break;
|
||||||
case OID_EXTENDED_KEY_USAGE:
|
case OID_EXTENDED_KEY_USAGE:
|
||||||
cert->isOcspSigner = parse_extendedKeyUsage(object, level);
|
cert->isOcspSigner = parse_extendedKeyUsage(object, level);
|
||||||
@@ -1052,6 +1053,14 @@ static iterator_t *create_crluri_iterator(const private_x509_t *this)
|
|||||||
return this->crlDistributionPoints->create_iterator(this->crlDistributionPoints, TRUE);
|
return this->crlDistributionPoints->create_iterator(this->crlDistributionPoints, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements x509_t.create_crluri_iterator
|
||||||
|
*/
|
||||||
|
static iterator_t *create_ocspuri_iterator(const private_x509_t *this)
|
||||||
|
{
|
||||||
|
return this->ocspAccessLocations->create_iterator(this->ocspAccessLocations, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements x509_t.verify
|
* Implements x509_t.verify
|
||||||
*/
|
*/
|
||||||
@@ -1193,6 +1202,8 @@ static void destroy(private_x509_t *this)
|
|||||||
offsetof(identification_t, destroy));
|
offsetof(identification_t, destroy));
|
||||||
this->crlDistributionPoints->destroy_offset(this->crlDistributionPoints,
|
this->crlDistributionPoints->destroy_offset(this->crlDistributionPoints,
|
||||||
offsetof(identification_t, destroy));
|
offsetof(identification_t, destroy));
|
||||||
|
this->ocspAccessLocations->destroy_offset(this->ocspAccessLocations,
|
||||||
|
offsetof(identification_t, destroy));
|
||||||
DESTROY_IF(this->issuer);
|
DESTROY_IF(this->issuer);
|
||||||
DESTROY_IF(this->subject);
|
DESTROY_IF(this->subject);
|
||||||
DESTROY_IF(this->public_key);
|
DESTROY_IF(this->public_key);
|
||||||
@@ -1214,6 +1225,7 @@ x509_t *x509_create_from_chunk(chunk_t chunk)
|
|||||||
this->issuer = NULL;
|
this->issuer = NULL;
|
||||||
this->subjectAltNames = linked_list_create();
|
this->subjectAltNames = linked_list_create();
|
||||||
this->crlDistributionPoints = linked_list_create();
|
this->crlDistributionPoints = linked_list_create();
|
||||||
|
this->ocspAccessLocations = linked_list_create();
|
||||||
this->subjectKeyID = chunk_empty;
|
this->subjectKeyID = chunk_empty;
|
||||||
this->authKeyID = chunk_empty;
|
this->authKeyID = chunk_empty;
|
||||||
this->authKeySerialNumber = chunk_empty;
|
this->authKeySerialNumber = chunk_empty;
|
||||||
@@ -1237,6 +1249,7 @@ x509_t *x509_create_from_chunk(chunk_t chunk)
|
|||||||
this->public.set_status = (void (*) (x509_t*,cert_status_t))set_status;
|
this->public.set_status = (void (*) (x509_t*,cert_status_t))set_status;
|
||||||
this->public.get_status = (cert_status_t (*) (const x509_t*))get_status;
|
this->public.get_status = (cert_status_t (*) (const x509_t*))get_status;
|
||||||
this->public.create_crluri_iterator = (iterator_t* (*) (const x509_t*))create_crluri_iterator;
|
this->public.create_crluri_iterator = (iterator_t* (*) (const x509_t*))create_crluri_iterator;
|
||||||
|
this->public.create_ocspuri_iterator = (iterator_t* (*) (const x509_t*))create_ocspuri_iterator;
|
||||||
this->public.verify = (bool (*) (const x509_t*,const rsa_public_key_t*))verify;
|
this->public.verify = (bool (*) (const x509_t*,const rsa_public_key_t*))verify;
|
||||||
this->public.destroy = (void (*) (x509_t*))destroy;
|
this->public.destroy = (void (*) (x509_t*))destroy;
|
||||||
|
|
||||||
|
|||||||
@@ -148,6 +148,14 @@ struct x509_t {
|
|||||||
*/
|
*/
|
||||||
iterator_t *(*create_crluri_iterator) (const x509_t *this);
|
iterator_t *(*create_crluri_iterator) (const x509_t *this);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create an iterator for the ocspAccessLocations.
|
||||||
|
*
|
||||||
|
* @param this calling object
|
||||||
|
* @return iterator for ocspAccessLocations
|
||||||
|
*/
|
||||||
|
iterator_t *(*create_ocspuri_iterator) (const x509_t *this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Check if a certificate is trustworthy
|
* @brief Check if a certificate is trustworthy
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user