diff options
author | Andreas Steffen <andreas.steffen@strongswan.org> | 2007-08-14 12:27:02 +0000 |
---|---|---|
committer | Andreas Steffen <andreas.steffen@strongswan.org> | 2007-08-14 12:27:02 +0000 |
commit | 06faefe43d21af02f457b4d2f33c921b27547caf (patch) | |
tree | 7b5f034aa349b7bf5b2b35b58294dd354df2bb30 /src/charon | |
parent | efddbcb0b553b2f8f81874ab2fe1a8159e19af82 (diff) | |
download | strongswan-06faefe43d21af02f457b4d2f33c921b27547caf.tar.bz2 strongswan-06faefe43d21af02f457b4d2f33c921b27547caf.tar.xz |
adding attribute certficates to a chained list
Diffstat (limited to 'src/charon')
-rw-r--r-- | src/charon/config/credentials/local_credential_store.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/charon/config/credentials/local_credential_store.c b/src/charon/config/credentials/local_credential_store.c index 60a01778f..3bd1db320 100644 --- a/src/charon/config/credentials/local_credential_store.c +++ b/src/charon/config/credentials/local_credential_store.c @@ -258,7 +258,6 @@ static status_t get_key(linked_list_t *keys, } } - /** * Implementation of local_credential_store_t.get_shared_key. */ @@ -1093,9 +1092,32 @@ static void load_aa_certificates(private_local_credential_store_t *this) */ static void add_attr_certificate(private_local_credential_store_t *this, x509ac_t *cert) { - /* TODO replace stale attribute certificates by fresh ones */ + iterator_t *iterator; + x509ac_t *current_cert; + pthread_mutex_lock(&(this->acerts_mutex)); - this->acerts->insert_last(this->acerts, (void*)cert); + iterator = this->acerts->create_iterator(this->acerts, TRUE); + + while (iterator->iterate(iterator, (void **)¤t_cert)) + { + if (cert->equals_holder(cert, current_cert)) + { + if (cert->is_newer(cert, current_cert)) + { + iterator->replace(iterator, NULL, (void *)cert); + current_cert->destroy(current_cert); + DBG1(DBG_CFG, " this attr cert is newer - existing attr cert replaced"); + } + else + { + cert->destroy(cert); + DBG1(DBG_CFG, " this attr cert is not newer - existing attr cert retained"); + } + break; + } + } + + iterator->destroy(iterator); pthread_mutex_unlock(&(this->acerts_mutex)); } |