moved very stroke specific x509 flag handling out of core library

This commit is contained in:
Martin Willi
2009-05-18 10:42:16 +02:00
parent 7736a40448
commit 24cd2ca6ee
2 changed files with 45 additions and 27 deletions
+10 -21
View File
@@ -1350,33 +1350,22 @@ static bool generate(private_builder_t *this)
static private_x509_cert_t *build(private_builder_t *this)
{
private_x509_cert_t *cert;
x509_flag_t flags;
if (this->cert && !this->cert->encoding.ptr)
if (this->cert)
{
if (!this->sign_key || !this->cert ||
!generate(this))
{
destroy(this->cert);
free(this);
return NULL;
this->cert->flags |= this->flags;
if (!this->cert->encoding.ptr)
{ /* generate a new certificate */
if (!this->sign_key || !generate(this))
{
destroy(this->cert);
free(this);
return NULL;
}
}
}
cert = this->cert;
flags = this->flags;
free(this);
if (cert == NULL)
{
return NULL;
}
if ((flags & X509_CA) && !(cert->flags & X509_CA))
{
DBG1(" ca certificate must have ca basic constraint set, discarded");
destroy(cert);
return NULL;
}
cert->flags |= flags;
return cert;
}