fallback to random end entity certificate if trustchain building fails
This commit is contained in:
@@ -1106,7 +1106,6 @@ static auth_info_t *build_trustchain(private_credential_manager_t *this,
|
|||||||
trustchain->add_item(trustchain, AUTHZ_SUBJECT_CERT, subject);
|
trustchain->add_item(trustchain, AUTHZ_SUBJECT_CERT, subject);
|
||||||
return trustchain;
|
return trustchain;
|
||||||
}
|
}
|
||||||
|
|
||||||
current = subject->get_ref(subject);
|
current = subject->get_ref(subject);
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
@@ -1188,7 +1187,7 @@ static private_key_t *get_private(private_credential_manager_t *this,
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->mutex->lock(this->mutex);
|
this->mutex->lock(this->mutex);
|
||||||
/* get all available end entity certificates for ourself */
|
/* try to build a trustchain for each certificate found */
|
||||||
enumerator = create_cert_enumerator(this, CERT_ANY, type, id, FALSE);
|
enumerator = create_cert_enumerator(this, CERT_ANY, type, id, FALSE);
|
||||||
while (enumerator->enumerate(enumerator, &cert))
|
while (enumerator->enumerate(enumerator, &cert))
|
||||||
{
|
{
|
||||||
@@ -1203,9 +1202,25 @@ static private_key_t *get_private(private_credential_manager_t *this,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
private->destroy(private);
|
private->destroy(private);
|
||||||
|
private = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
enumerator->destroy(enumerator);
|
enumerator->destroy(enumerator);
|
||||||
|
/* if no valid trustchain was found, fall back to the first usable cert */
|
||||||
|
if (!private)
|
||||||
|
{
|
||||||
|
enumerator = create_cert_enumerator(this, CERT_ANY, type, id, FALSE);
|
||||||
|
while (enumerator->enumerate(enumerator, &cert))
|
||||||
|
{
|
||||||
|
private = get_private_by_cert(this, cert, type);
|
||||||
|
if (private)
|
||||||
|
{
|
||||||
|
auth->add_item(auth, AUTHZ_SUBJECT_CERT, cert);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
enumerator->destroy(enumerator);
|
||||||
|
}
|
||||||
this->mutex->unlock(this->mutex);
|
this->mutex->unlock(this->mutex);
|
||||||
return private;
|
return private;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user