- applied patch from andreas, which allows certificate listing via stroke
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include <crypto/rsa/rsa_private_key.h>
|
||||
#include <crypto/rsa/rsa_public_key.h>
|
||||
#include <utils/identification.h>
|
||||
#include <utils/logger.h>
|
||||
|
||||
|
||||
typedef struct credential_store_t credential_store_t;
|
||||
@@ -80,6 +81,15 @@ struct credential_store_t {
|
||||
*/
|
||||
rsa_private_key_t *(*get_rsa_private_key) (credential_store_t *this, identification_t *identification);
|
||||
|
||||
/**
|
||||
* @brief Lists all certificates kept in the local credential store.
|
||||
*
|
||||
* @param this calling object
|
||||
* @param logger logger to be used
|
||||
* @param utc log dates either in UTC or local time
|
||||
*/
|
||||
void (*log_certificates) (credential_store_t *this, logger_t *logger, bool utc);
|
||||
|
||||
/**
|
||||
* @brief Destroys a credential_store_t object.
|
||||
*
|
||||
|
||||
@@ -140,6 +140,30 @@ static rsa_private_key_t *get_rsa_private_key(private_local_credential_store_t *
|
||||
return found;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements credential_store_t.log_certificates
|
||||
*/
|
||||
static void log_certificates(private_local_credential_store_t *this, logger_t *logger, bool utc)
|
||||
{
|
||||
iterator_t *iterator = this->certificates->create_iterator(this->certificates, TRUE);
|
||||
|
||||
if (iterator->get_count(iterator))
|
||||
{
|
||||
logger->log(logger, CONTROL, "");
|
||||
logger->log(logger, CONTROL, "List of X.509 End Entity Certificates:");
|
||||
logger->log(logger, CONTROL, "");
|
||||
}
|
||||
|
||||
while (iterator->has_next(iterator))
|
||||
{
|
||||
x509_t *cert;
|
||||
|
||||
iterator->current(iterator, (void**)&cert);
|
||||
cert->log_certificate(cert, logger, utc);
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements local_credential_store_t.load_certificates
|
||||
*/
|
||||
@@ -187,8 +211,8 @@ static void load_certificates(private_local_credential_store_t *this, const char
|
||||
*/
|
||||
static identification_t *get_id_for_private_key(private_local_credential_store_t *this, rsa_private_key_t *private_key)
|
||||
{
|
||||
iterator_t *iterator;
|
||||
x509_t *cert;
|
||||
iterator_t *iterator;
|
||||
identification_t *found = NULL;
|
||||
rsa_public_key_t *public_key;
|
||||
|
||||
@@ -368,6 +392,7 @@ local_credential_store_t * local_credential_store_create(void)
|
||||
this->public.credential_store.get_shared_secret = (status_t(*)(credential_store_t*,identification_t*,chunk_t*))get_shared_secret;
|
||||
this->public.credential_store.get_rsa_private_key = (rsa_private_key_t*(*)(credential_store_t*,identification_t*))get_rsa_private_key;
|
||||
this->public.credential_store.get_rsa_public_key = (rsa_public_key_t*(*)(credential_store_t*,identification_t*))get_rsa_public_key;
|
||||
this->public.credential_store.log_certificates = (void(*)(credential_store_t*,logger_t*,bool))log_certificates;
|
||||
this->public.load_certificates = (void(*)(local_credential_store_t*,const char*))load_certificates;
|
||||
this->public.load_private_keys = (void(*)(local_credential_store_t*,const char*, const char*))load_private_keys;
|
||||
this->public.credential_store.destroy = (void(*)(credential_store_t*))destroy;
|
||||
|
||||
@@ -52,7 +52,7 @@ struct local_credential_store_t {
|
||||
/**
|
||||
* @brief Loads trusted certificates from a folder.
|
||||
*
|
||||
* Currently, all keys must be in binary DER format.
|
||||
* Certificates in both DER and PEM format are accepted
|
||||
*
|
||||
* @param this calling object
|
||||
* @param path directory to load certificates from
|
||||
@@ -60,10 +60,10 @@ struct local_credential_store_t {
|
||||
void (*load_certificates) (local_credential_store_t *this, const char *path);
|
||||
|
||||
/**
|
||||
* @brief Loads RSA private keys from a folder.
|
||||
* @brief Loads RSA private keys defined in ipsec.secrets
|
||||
*
|
||||
* Currently, all keys must be unencrypted in binary DER format. Anything
|
||||
* other gets ignored. Further, a certificate for the specific private
|
||||
* Currently, all keys must be unencrypted in either DER or PEM format.
|
||||
* Other formats are ignored. Further, a certificate for the specific private
|
||||
* key must already be loaded to get the ID from.
|
||||
*
|
||||
* @param this calling object
|
||||
|
||||
Reference in New Issue
Block a user