introduced new logging subsystem using bus:
passive listeners can register on the bus active listeners wait for signals actively multiplexing allows multiple listeners to receive debug signals a lot more...
This commit is contained in:
@@ -29,7 +29,6 @@
|
||||
#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;
|
||||
@@ -136,31 +135,28 @@ struct credential_store_t {
|
||||
x509_t* (*add_ca_certificate) (credential_store_t *this, x509_t *cert);
|
||||
|
||||
/**
|
||||
* @brief Lists all certificates kept in the local credential store.
|
||||
* @brief Create an iterator over all end certificates.
|
||||
*
|
||||
* @param this calling object
|
||||
* @param logger logger to be used
|
||||
* @param utc log dates either in UTC or local time
|
||||
* @return iterator
|
||||
*/
|
||||
void (*log_certificates) (credential_store_t *this, logger_t *logger, bool utc);
|
||||
iterator_t* (*create_cert_iterator) (credential_store_t *this);
|
||||
|
||||
/**
|
||||
* @brief Lists all CA certificates kept in the local credential store.
|
||||
* @brief Create an iterator over all CA certificates.
|
||||
*
|
||||
* @param this calling object
|
||||
* @param logger logger to be used
|
||||
* @param utc log dates either in UTC or local time
|
||||
* @return iterator
|
||||
*/
|
||||
void (*log_ca_certificates) (credential_store_t *this, logger_t *logger, bool utc);
|
||||
iterator_t* (*create_cacert_iterator) (credential_store_t *this);
|
||||
|
||||
/**
|
||||
* @brief Lists all CRLs kept in the local credential store.
|
||||
* @brief Create an iterator over all CRLs.
|
||||
*
|
||||
* @param this calling object
|
||||
* @param logger logger to be used
|
||||
* @param utc log dates either in UTC or local time
|
||||
* @return iterator
|
||||
*/
|
||||
void (*log_crls) (credential_store_t *this, logger_t *logger, bool utc);
|
||||
iterator_t* (*create_crl_iterator) (credential_store_t *this);
|
||||
|
||||
/**
|
||||
* @brief Loads trusted CA certificates from a default directory.
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <types.h>
|
||||
#include <utils/lexparser.h>
|
||||
#include <utils/linked_list.h>
|
||||
#include <utils/logger_manager.h>
|
||||
#include <crypto/certinfo.h>
|
||||
#include <crypto/rsa/rsa_public_key.h>
|
||||
#include <crypto/x509.h>
|
||||
@@ -56,13 +55,6 @@ struct shared_key_t {
|
||||
* list of peer IDs
|
||||
*/
|
||||
linked_list_t *peers;
|
||||
|
||||
/**
|
||||
* @brief Destroys a shared_key_t object.
|
||||
*
|
||||
* @param this calling object
|
||||
*/
|
||||
void (*destroy) (shared_key_t *this);
|
||||
};
|
||||
|
||||
|
||||
@@ -88,7 +80,6 @@ static void shared_key_destroy(shared_key_t *this)
|
||||
* @brief Creates a shared_key_t object.
|
||||
*
|
||||
* @param shared_key shared key value
|
||||
*
|
||||
* @return shared_key_t object
|
||||
*
|
||||
* @ingroup config
|
||||
@@ -97,9 +88,6 @@ static shared_key_t *shared_key_create(chunk_t secret)
|
||||
{
|
||||
shared_key_t *this = malloc_thing(shared_key_t);
|
||||
|
||||
/* private functions */
|
||||
this->destroy = shared_key_destroy;
|
||||
|
||||
/* private data */
|
||||
this->secret = chunk_clone(secret);
|
||||
this->peers = linked_list_create();
|
||||
@@ -154,11 +142,6 @@ struct private_local_credential_store_t {
|
||||
* enforce strict crl policy
|
||||
*/
|
||||
bool strict;
|
||||
|
||||
/**
|
||||
* Assigned logger
|
||||
*/
|
||||
logger_t *logger;
|
||||
};
|
||||
|
||||
|
||||
@@ -285,20 +268,19 @@ static rsa_public_key_t *get_trusted_public_key(private_local_credential_store_t
|
||||
ugh = cert->is_valid(cert, NULL);
|
||||
if (ugh != NULL)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR, "certificate %s");
|
||||
DBG1(SIG_DBG_CFG, "certificate %s", ugh);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
status = cert->get_status(cert);
|
||||
if (status == CERT_REVOKED || status == CERT_UNTRUSTED || (this->strict && status != CERT_GOOD))
|
||||
{
|
||||
this->logger->log(this->logger, ERROR, "certificate status: %s",
|
||||
enum_name(&cert_status_names, status));
|
||||
DBG1(SIG_DBG_CFG, "certificate status: %N", cert_status_names, status);
|
||||
return NULL;
|
||||
}
|
||||
if (status == CERT_GOOD && cert->get_until(cert) < time(NULL))
|
||||
{
|
||||
this->logger->log(this->logger, ERROR, "certificate is good but crl is stale");
|
||||
DBG1(SIG_DBG_CFG, "certificate is good but crl is stale");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -419,20 +401,20 @@ static cert_status_t verify_by_crl(private_local_credential_store_t* this, const
|
||||
crl = get_crl(this, issuer_cert);
|
||||
if (crl == NULL)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR, "crl not found");
|
||||
DBG1(SIG_DBG_CFG, "crl not found");
|
||||
goto err;
|
||||
}
|
||||
this->logger->log(this->logger, CONTROL|LEVEL1, "crl found");
|
||||
DBG2(SIG_DBG_CFG, "crl found");
|
||||
|
||||
issuer_public_key = issuer_cert->get_public_key(issuer_cert);
|
||||
issuer_public_key = issuer_cert->get_public_key(issuer_cert);
|
||||
valid_signature = crl->verify(crl, issuer_public_key);
|
||||
|
||||
if (!valid_signature)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR, "crl signature is invalid");
|
||||
DBG1(SIG_DBG_CFG, "crl signature is invalid");
|
||||
goto err;
|
||||
}
|
||||
this->logger->log(this->logger, CONTROL|LEVEL1, "crl signature is valid");
|
||||
DBG2(SIG_DBG_CFG, "crl signature is valid");
|
||||
|
||||
crl->get_status(crl, certinfo);
|
||||
|
||||
@@ -490,8 +472,8 @@ static bool verify(private_local_credential_store_t *this, x509_t *cert, bool *f
|
||||
*found = (cert_copy != NULL);
|
||||
if (*found)
|
||||
{
|
||||
this->logger->log(this->logger, CONTROL|LEVEL1,
|
||||
"end entitity certificate is already in credential store");
|
||||
DBG2(SIG_DBG_CFG,
|
||||
"end entitity certificate is already in credential store");
|
||||
}
|
||||
|
||||
for (pathlen = 0; pathlen < MAX_CA_PATH_LEN; pathlen++)
|
||||
@@ -504,39 +486,39 @@ static bool verify(private_local_credential_store_t *this, x509_t *cert, bool *f
|
||||
identification_t *subject = cert->get_subject(cert);
|
||||
identification_t *issuer = cert->get_issuer(cert);
|
||||
|
||||
this->logger->log(this->logger, CONTROL|LEVEL1, "subject: '%D'", subject);
|
||||
this->logger->log(this->logger, CONTROL|LEVEL1, "issuer: '%D'", issuer);
|
||||
DBG2(SIG_DBG_CFG, "subject: '%D'", subject);
|
||||
DBG2(SIG_DBG_CFG, "issuer: '%D'", issuer);
|
||||
|
||||
ugh = cert->is_valid(cert, &until);
|
||||
if (ugh != NULL)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR, "certificate %s", ugh);
|
||||
DBG1(SIG_DBG_CFG, "certificate %s", ugh);
|
||||
return FALSE;
|
||||
}
|
||||
this->logger->log(this->logger, CONTROL|LEVEL1, "certificate is valid");
|
||||
DBG2(SIG_DBG_CFG, "certificate is valid");
|
||||
|
||||
issuer_cert = get_issuer_certificate(this, cert);
|
||||
if (issuer_cert == NULL)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR, "issuer certificate not found");
|
||||
DBG1(SIG_DBG_CFG, "issuer certificate not found");
|
||||
return FALSE;
|
||||
}
|
||||
this->logger->log(this->logger, CONTROL|LEVEL1, "issuer certificate found");
|
||||
DBG2(SIG_DBG_CFG, "issuer certificate found");
|
||||
|
||||
issuer_public_key = issuer_cert->get_public_key(issuer_cert);
|
||||
valid_signature = cert->verify(cert, issuer_public_key);
|
||||
|
||||
if (!valid_signature)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR, "certificate signature is invalid");
|
||||
DBG1(SIG_DBG_CFG, "certificate signature is invalid");
|
||||
return FALSE;
|
||||
}
|
||||
this->logger->log(this->logger, CONTROL|LEVEL1, "certificate signature is valid");
|
||||
DBG2(SIG_DBG_CFG, "certificate signature is valid");
|
||||
|
||||
/* check if cert is a self-signed root ca */
|
||||
if (pathlen > 0 && cert->is_self_signed(cert))
|
||||
{
|
||||
this->logger->log(this->logger, CONTROL|LEVEL1, "reached self-signed root ca");
|
||||
DBG2(SIG_DBG_CFG, "reached self-signed root ca");
|
||||
|
||||
/* set the definite status and trust interval of the end entity certificate */
|
||||
end_cert->set_until(end_cert, until);
|
||||
@@ -576,10 +558,10 @@ static bool verify(private_local_credential_store_t *this, x509_t *cert, bool *f
|
||||
/* if status information is stale */
|
||||
if (this->strict && nextUpdate < time(NULL))
|
||||
{
|
||||
this->logger->log(this->logger, CONTROL|LEVEL1, "certificate is good but status is stale");
|
||||
DBG2(SIG_DBG_CFG, "certificate is good but status is stale");
|
||||
return FALSE;
|
||||
}
|
||||
this->logger->log(this->logger, CONTROL|LEVEL1, "certificate is good");
|
||||
DBG2(SIG_DBG_CFG, "certificate is good");
|
||||
|
||||
/* with strict crl policy the public key must have the same
|
||||
* lifetime as the validity of the ocsp status or crl lifetime
|
||||
@@ -589,12 +571,11 @@ static bool verify(private_local_credential_store_t *this, x509_t *cert, bool *f
|
||||
break;
|
||||
case CERT_REVOKED:
|
||||
{
|
||||
u_char buf[TIMETOA_BUF];
|
||||
time_t revocationTime = certinfo->get_revocationTime(certinfo);
|
||||
|
||||
timetoa(buf, TIMETOA_BUF, &revocationTime, TRUE);
|
||||
this->logger->log(this->logger, ERROR, "certificate was revoked on %s, reason: %s",
|
||||
buf, certinfo->get_revocationReason(certinfo));
|
||||
DBG1(SIG_DBG_CFG,
|
||||
"certificate was revoked on %T, reason: %N",
|
||||
revocationTime, crl_reason_names,
|
||||
certinfo->get_revocationReason(certinfo));
|
||||
|
||||
/* set revocationTime */
|
||||
cert->set_until(cert, revocationTime);
|
||||
@@ -609,7 +590,8 @@ static bool verify(private_local_credential_store_t *this, x509_t *cert, bool *f
|
||||
else
|
||||
{
|
||||
cert_copy->set_status(cert_copy, CERT_REVOKED);
|
||||
cert_copy->set_until(cert_copy, certinfo->get_revocationTime(certinfo));
|
||||
cert_copy->set_until(cert_copy,
|
||||
certinfo->get_revocationTime(certinfo));
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
@@ -617,7 +599,7 @@ static bool verify(private_local_credential_store_t *this, x509_t *cert, bool *f
|
||||
case CERT_UNKNOWN:
|
||||
case CERT_UNDEFINED:
|
||||
default:
|
||||
this->logger->log(this->logger, CONTROL|LEVEL1, "certificate status unknown");
|
||||
DBG2(SIG_DBG_CFG, "certificate status unknown");
|
||||
if (this->strict)
|
||||
{
|
||||
/* update status of end certificate in the credential store */
|
||||
@@ -634,7 +616,7 @@ static bool verify(private_local_credential_store_t *this, x509_t *cert, bool *f
|
||||
/* go up one step in the trust chain */
|
||||
cert = issuer_cert;
|
||||
}
|
||||
this->logger->log(this->logger, ERROR, "maximum ca path length of %d levels exceeded", MAX_CA_PATH_LEN);
|
||||
DBG1(SIG_DBG_CFG, "maximum ca path length of %d levels exceeded", MAX_CA_PATH_LEN);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -674,80 +656,27 @@ static x509_t* add_ca_certificate(private_local_credential_store_t *this, x509_t
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements local_credential_store_t.log_certificates
|
||||
* Implements local_credential_store_t.create_cert_iterator
|
||||
*/
|
||||
static void log_certificates(private_local_credential_store_t *this, logger_t *logger, bool utc)
|
||||
static iterator_t* create_cert_iterator(private_local_credential_store_t *this)
|
||||
{
|
||||
iterator_t *iterator = this->certs->create_iterator(this->certs, 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;
|
||||
bool has_key;
|
||||
|
||||
iterator->current(iterator, (void**)&cert);
|
||||
has_key = has_rsa_private_key(this, cert->get_public_key(cert));
|
||||
cert->log_certificate(cert, logger, utc, has_key);
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
return this->certs->create_iterator(this->certs, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements local_credential_store_t.log_ca_certificates
|
||||
* Implements local_credential_store_t.create_cacert_iterator
|
||||
*/
|
||||
static void log_ca_certificates(private_local_credential_store_t *this, logger_t *logger, bool utc)
|
||||
static iterator_t* create_cacert_iterator(private_local_credential_store_t *this)
|
||||
{
|
||||
iterator_t *iterator = this->ca_certs->create_iterator(this->ca_certs, TRUE);
|
||||
|
||||
if (iterator->get_count(iterator))
|
||||
{
|
||||
logger->log(logger, CONTROL, "");
|
||||
logger->log(logger, CONTROL, "List of X.509 CA Certificates:");
|
||||
logger->log(logger, CONTROL, "");
|
||||
}
|
||||
|
||||
while (iterator->has_next(iterator))
|
||||
{
|
||||
x509_t *cert;
|
||||
|
||||
iterator->current(iterator, (void**)&cert);
|
||||
cert->log_certificate(cert, logger, utc, FALSE);
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
return this->ca_certs->create_iterator(this->ca_certs, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements local_credential_store_t.log_crls
|
||||
* Implements local_credential_store_t.create_crl_iterator
|
||||
*/
|
||||
static void log_crls(private_local_credential_store_t *this, logger_t *logger, bool utc)
|
||||
static iterator_t* create_crl_iterator(private_local_credential_store_t *this)
|
||||
{
|
||||
iterator_t *iterator = this->crls->create_iterator(this->crls, TRUE);
|
||||
|
||||
pthread_mutex_lock(&(this->crls_mutex));
|
||||
if (iterator->get_count(iterator))
|
||||
{
|
||||
logger->log(logger, CONTROL, "");
|
||||
logger->log(logger, CONTROL, "List of X.509 CRLs:");
|
||||
logger->log(logger, CONTROL, "");
|
||||
}
|
||||
|
||||
while (iterator->has_next(iterator))
|
||||
{
|
||||
crl_t *crl;
|
||||
|
||||
iterator->current(iterator, (void**)&crl);
|
||||
crl->log_crl(crl, logger, utc, this->strict);
|
||||
}
|
||||
pthread_mutex_unlock(&(this->crls_mutex));
|
||||
|
||||
iterator->destroy(iterator);
|
||||
return this->crls->create_iterator_locked(this->crls, &(this->crls_mutex));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -760,12 +689,12 @@ static void load_ca_certificates(private_local_credential_store_t *this)
|
||||
DIR* dir;
|
||||
x509_t *cert;
|
||||
|
||||
this->logger->log(this->logger, CONTROL, "loading ca certificates from '%s/'", CA_CERTIFICATE_DIR);
|
||||
DBG1(SIG_DBG_CFG, "loading ca certificates from '%s/'", CA_CERTIFICATE_DIR);
|
||||
|
||||
dir = opendir(CA_CERTIFICATE_DIR);
|
||||
if (dir == NULL)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR, "error opening ca certs directory %s'", CA_CERTIFICATE_DIR);
|
||||
DBG1(SIG_DBG_CFG, "error opening ca certs directory %s'", CA_CERTIFICATE_DIR);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -787,9 +716,9 @@ static void load_ca_certificates(private_local_credential_store_t *this)
|
||||
{
|
||||
err_t ugh = cert->is_valid(cert, NULL);
|
||||
|
||||
if (ugh != NULL)
|
||||
if (ugh != NULL)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR, "warning: ca certificate %s", ugh);
|
||||
DBG1(SIG_DBG_CFG, "warning: ca certificate %s", ugh);
|
||||
}
|
||||
if (cert->is_ca(cert))
|
||||
{
|
||||
@@ -797,8 +726,7 @@ static void load_ca_certificates(private_local_credential_store_t *this)
|
||||
}
|
||||
else
|
||||
{
|
||||
this->logger->log(this->logger, ERROR,
|
||||
" CA basic constraints flag not set, cert discarded");
|
||||
DBG1(SIG_DBG_CFG, " CA basic constraints flag not set, cert discarded");
|
||||
cert->destroy(cert);
|
||||
}
|
||||
}
|
||||
@@ -810,7 +738,7 @@ static void load_ca_certificates(private_local_credential_store_t *this)
|
||||
/**
|
||||
* Add the latest crl to a linked list
|
||||
*/
|
||||
static crl_t* add_crl(linked_list_t *crls, crl_t *crl, logger_t *logger)
|
||||
static crl_t* add_crl(linked_list_t *crls, crl_t *crl)
|
||||
{
|
||||
bool found = FALSE;
|
||||
|
||||
@@ -833,13 +761,13 @@ static crl_t* add_crl(linked_list_t *crls, crl_t *crl, logger_t *logger)
|
||||
{
|
||||
old_crl->destroy(old_crl);
|
||||
}
|
||||
logger->log(logger, CONTROL|LEVEL1, " thisUpdate is newer - existing crl replaced");
|
||||
DBG2(SIG_DBG_CFG, " thisUpdate is newer - existing crl replaced");
|
||||
}
|
||||
else
|
||||
{
|
||||
crl->destroy(crl);
|
||||
crl = current_crl;
|
||||
logger->log(logger, CONTROL|LEVEL1, " thisUpdate is not newer - existing crl retained");
|
||||
DBG2(SIG_DBG_CFG, " thisUpdate is not newer - existing crl retained");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -849,7 +777,7 @@ static crl_t* add_crl(linked_list_t *crls, crl_t *crl, logger_t *logger)
|
||||
if (!found)
|
||||
{
|
||||
crls->insert_last(crls, (void*)crl);
|
||||
logger->log(logger, CONTROL|LEVEL1, " crl added");
|
||||
DBG2(SIG_DBG_CFG, " crl added");
|
||||
}
|
||||
return crl;
|
||||
}
|
||||
@@ -864,12 +792,12 @@ static void load_crls(private_local_credential_store_t *this)
|
||||
DIR* dir;
|
||||
crl_t *crl;
|
||||
|
||||
this->logger->log(this->logger, CONTROL, "loading crls from '%s/'", CRL_DIR);
|
||||
DBG1(SIG_DBG_CFG, "loading crls from '%s/'", CRL_DIR);
|
||||
|
||||
dir = opendir(CRL_DIR);
|
||||
if (dir == NULL)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR, "error opening crl directory %s'", CRL_DIR);
|
||||
DBG1(SIG_DBG_CFG, "error opening crl directory %s'", CRL_DIR);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -893,10 +821,10 @@ static void load_crls(private_local_credential_store_t *this)
|
||||
|
||||
if (ugh != NULL)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR, "warning: crl %s", ugh);
|
||||
DBG1(SIG_DBG_CFG, "warning: crl %s", ugh);
|
||||
}
|
||||
pthread_mutex_lock(&(this->crls_mutex));
|
||||
crl = add_crl(this->crls, crl, this->logger);
|
||||
crl = add_crl(this->crls, crl);
|
||||
pthread_mutex_unlock(&(this->crls_mutex));
|
||||
}
|
||||
}
|
||||
@@ -973,7 +901,7 @@ static void load_secrets(private_local_credential_store_t *this)
|
||||
int line_nr = 0;
|
||||
chunk_t chunk, src, line;
|
||||
|
||||
this->logger->log(this->logger, CONTROL, "loading secrets from \"%s\"", SECRETS_FILE);
|
||||
DBG1(SIG_DBG_CFG, "loading secrets from \"%s\"", SECRETS_FILE);
|
||||
|
||||
fseek(fd, 0, SEEK_END);
|
||||
chunk.len = ftell(fd);
|
||||
@@ -996,7 +924,7 @@ static void load_secrets(private_local_credential_store_t *this)
|
||||
}
|
||||
if (!extract_token(&ids, ':', &line))
|
||||
{
|
||||
this->logger->log(this->logger, ERROR, "line %d: missing ':' separator", line_nr);
|
||||
DBG1(SIG_DBG_CFG, "line %d: missing ':' separator", line_nr);
|
||||
goto error;
|
||||
}
|
||||
/* NULL terminate the ids string by replacing the : separator */
|
||||
@@ -1004,7 +932,7 @@ static void load_secrets(private_local_credential_store_t *this)
|
||||
|
||||
if (!eat_whitespace(&line) || !extract_token(&token, ' ', &line))
|
||||
{
|
||||
this->logger->log(this->logger, ERROR, "line %d: missing token", line_nr);
|
||||
DBG1(SIG_DBG_CFG, "line %d: missing token", line_nr);
|
||||
goto error;
|
||||
}
|
||||
if (match("RSA", &token))
|
||||
@@ -1022,13 +950,12 @@ static void load_secrets(private_local_credential_store_t *this)
|
||||
|
||||
if (ugh != NULL)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR, "line %d: %s", line_nr, ugh);
|
||||
DBG1(SIG_DBG_CFG, "line %d: %s", line_nr, ugh);
|
||||
goto error;
|
||||
}
|
||||
if (filename.len == 0)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR,
|
||||
"line %d: empty filename", line_nr);
|
||||
DBG1(SIG_DBG_CFG, "line %d: empty filename", line_nr);
|
||||
goto error;
|
||||
}
|
||||
if (*filename.ptr == '/')
|
||||
@@ -1049,8 +976,7 @@ static void load_secrets(private_local_credential_store_t *this)
|
||||
ugh = extract_secret(&secret, &line);
|
||||
if (ugh != NULL)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR,
|
||||
"line %d: malformed passphrase: %s", line_nr, ugh);
|
||||
DBG1(SIG_DBG_CFG, "line %d: malformed passphrase: %s", line_nr, ugh);
|
||||
goto error;
|
||||
}
|
||||
if (secret.len > 0)
|
||||
@@ -1072,23 +998,20 @@ static void load_secrets(private_local_credential_store_t *this)
|
||||
err_t ugh = extract_secret(&secret, &line);
|
||||
if (ugh != NULL)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR,
|
||||
"line %d: malformed secret: %s", line_nr, ugh);
|
||||
DBG1(SIG_DBG_CFG, "line %d: malformed secret: %s", line_nr, ugh);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (ids.len > 0)
|
||||
{
|
||||
this->logger->log(this->logger, CONTROL,
|
||||
" loading shared key for %s", ids.ptr);
|
||||
DBG1(SIG_DBG_CFG, " loading shared key for %s", ids.ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->logger->log(this->logger, CONTROL,
|
||||
" loading shared key for %%any");
|
||||
DBG1(SIG_DBG_CFG, " loading shared key for %%any");
|
||||
}
|
||||
|
||||
this->logger->log_chunk(this->logger, PRIVATE, " secret:", secret);
|
||||
DBG4(SIG_DBG_CFG, " secret:", secret);
|
||||
|
||||
shared_key = shared_key_create(secret);
|
||||
if (shared_key)
|
||||
@@ -1103,8 +1026,7 @@ static void load_secrets(private_local_credential_store_t *this)
|
||||
ugh = extract_value(&id, &ids);
|
||||
if (ugh != NULL)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR,
|
||||
"line %d: %s", line_nr, ugh);
|
||||
DBG1(SIG_DBG_CFG, "line %d: %s", line_nr, ugh);
|
||||
goto error;
|
||||
}
|
||||
if (id.len == 0)
|
||||
@@ -1118,8 +1040,7 @@ static void load_secrets(private_local_credential_store_t *this)
|
||||
peer_id = identification_create_from_string(id.ptr);
|
||||
if (peer_id == NULL)
|
||||
{
|
||||
this->logger->log(this->logger, ERROR,
|
||||
"line %d: malformed ID: %s", line_nr, id.ptr);
|
||||
DBG1(SIG_DBG_CFG, "line %d: malformed ID: %s", line_nr, id.ptr);
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -1137,9 +1058,8 @@ static void load_secrets(private_local_credential_store_t *this)
|
||||
}
|
||||
else
|
||||
{
|
||||
this->logger->log(this->logger, ERROR,
|
||||
"line %d: token must be either RSA, PSK, or PIN",
|
||||
line_nr, token.len);
|
||||
DBG1(SIG_DBG_CFG, "line %d: token must be either "
|
||||
"RSA, PSK, or PIN", line_nr, token.len);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
@@ -1148,7 +1068,7 @@ error:
|
||||
}
|
||||
else
|
||||
{
|
||||
this->logger->log(this->logger, ERROR, "could not open file '%s'", SECRETS_FILE);
|
||||
DBG1(SIG_DBG_CFG, "could not open file '%s'", SECRETS_FILE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1195,7 +1115,7 @@ static void destroy(private_local_credential_store_t *this)
|
||||
/* destroy shared keys list */
|
||||
while (this->shared_keys->remove_last(this->shared_keys, (void**)&shared_key) == SUCCESS)
|
||||
{
|
||||
shared_key->destroy(shared_key);
|
||||
shared_key_destroy(shared_key);
|
||||
}
|
||||
this->shared_keys->destroy(this->shared_keys);
|
||||
|
||||
@@ -1218,9 +1138,9 @@ local_credential_store_t * local_credential_store_create(bool strict)
|
||||
this->public.credential_store.verify = (bool (*) (credential_store_t*,x509_t*,bool*))verify;
|
||||
this->public.credential_store.add_end_certificate = (x509_t* (*) (credential_store_t*,x509_t*))add_end_certificate;
|
||||
this->public.credential_store.add_ca_certificate = (x509_t* (*) (credential_store_t*,x509_t*))add_ca_certificate;
|
||||
this->public.credential_store.log_certificates = (void (*) (credential_store_t*,logger_t*,bool))log_certificates;
|
||||
this->public.credential_store.log_ca_certificates = (void (*) (credential_store_t*,logger_t*,bool))log_ca_certificates;
|
||||
this->public.credential_store.log_crls = (void (*) (credential_store_t*,logger_t*,bool))log_crls;
|
||||
this->public.credential_store.create_cert_iterator = (iterator_t* (*) (credential_store_t*))create_cert_iterator;
|
||||
this->public.credential_store.create_cacert_iterator = (iterator_t* (*) (credential_store_t*))create_cacert_iterator;
|
||||
this->public.credential_store.create_crl_iterator = (iterator_t* (*) (credential_store_t*))create_crl_iterator;
|
||||
this->public.credential_store.load_ca_certificates = (void (*) (credential_store_t*))load_ca_certificates;
|
||||
this->public.credential_store.load_crls = (void (*) (credential_store_t*))load_crls;
|
||||
this->public.credential_store.load_secrets = (void (*) (credential_store_t*))load_secrets;
|
||||
@@ -1230,13 +1150,12 @@ local_credential_store_t * local_credential_store_create(bool strict)
|
||||
pthread_mutex_init(&(this->crls_mutex), NULL);
|
||||
|
||||
/* private variables */
|
||||
this->shared_keys = linked_list_create();
|
||||
this->shared_keys = linked_list_create();
|
||||
this->private_keys = linked_list_create();
|
||||
this->certs = linked_list_create();
|
||||
this->ca_certs = linked_list_create();
|
||||
this->crls = linked_list_create();
|
||||
this->certs = linked_list_create();
|
||||
this->ca_certs = linked_list_create();
|
||||
this->crls = linked_list_create();
|
||||
this->strict = strict;
|
||||
this->logger = logger_manager->get_logger(logger_manager, CONFIG);
|
||||
|
||||
return (&this->public);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user