Load multiple comma seperarated certificates in the leftcert option

This commit is contained in:
Martin Willi
2013-01-18 09:33:15 +01:00
parent f29783af8c
commit 78af36db50
+32 -15
View File
@@ -447,25 +447,42 @@ static auth_cfg_t *build_auth_cfg(private_stroke_config_t *this,
identity = identification_create_from_string(id); identity = identification_create_from_string(id);
if (cert) if (cert)
{ {
certificate = this->cred->load_peer(this->cred, cert); enumerator_t *enumerator;
if (certificate) bool has_subject = FALSE;
certificate_t *first = NULL;
enumerator = enumerator_create_token(cert, ",", " ");
while (enumerator->enumerate(enumerator, &cert))
{ {
if (local) certificate = this->cred->load_peer(this->cred, cert);
if (certificate)
{ {
this->ca->check_for_hash_and_url(this->ca, certificate); if (local)
} {
cfg->add(cfg, AUTH_RULE_SUBJECT_CERT, certificate); this->ca->check_for_hash_and_url(this->ca, certificate);
if (identity->get_type(identity) == ID_ANY || }
!certificate->has_subject(certificate, identity)) cfg->add(cfg, AUTH_RULE_SUBJECT_CERT, certificate);
{ if (!first)
DBG1(DBG_CFG, " id '%Y' not confirmed by certificate, " {
"defaulting to '%Y'", identity, first = certificate;
certificate->get_subject(certificate)); }
identity->destroy(identity); if (identity->get_type(identity) != ID_ANY &&
identity = certificate->get_subject(certificate); certificate->has_subject(certificate, identity))
identity = identity->clone(identity); {
has_subject = TRUE;
}
} }
} }
enumerator->destroy(enumerator);
if (first && !has_subject)
{
DBG1(DBG_CFG, " id '%Y' not confirmed by certificate, "
"defaulting to '%Y'", identity, first->get_subject(first));
identity->destroy(identity);
identity = first->get_subject(first);
identity = identity->clone(identity);
}
} }
if (identity->get_type(identity) != ID_ANY) if (identity->get_type(identity) != ID_ANY)
{ {