aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/plugins/pubkey/pubkey_cert.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstrongswan/plugins/pubkey/pubkey_cert.c')
-rw-r--r--src/libstrongswan/plugins/pubkey/pubkey_cert.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/libstrongswan/plugins/pubkey/pubkey_cert.c b/src/libstrongswan/plugins/pubkey/pubkey_cert.c
index 63dffb47b..6305f46a7 100644
--- a/src/libstrongswan/plugins/pubkey/pubkey_cert.c
+++ b/src/libstrongswan/plugins/pubkey/pubkey_cert.c
@@ -238,27 +238,28 @@ static pubkey_cert_t *build(private_builder_t *this)
*/
static void add(private_builder_t *this, builder_part_t part, ...)
{
- va_list args;
-
- if (this->key)
+ if (!this->key)
{
- DBG1("ignoring surplus build part %N", builder_part_names, part);
- return;
- }
+ va_list args;
- switch (part)
- {
- case BUILD_PUBLIC_KEY:
+ switch (part)
{
- va_start(args, part);
- this->key = pubkey_cert_create(va_arg(args, public_key_t*));
- va_end(args);
- break;
+ case BUILD_PUBLIC_KEY:
+ {
+ va_start(args, part);
+ this->key = pubkey_cert_create(va_arg(args, public_key_t*));
+ va_end(args);
+ return;
+ }
+ default:
+ break;
}
- default:
- DBG1("ignoring unsupported build part %N", builder_part_names, part);
- break;
}
+ if (this->key)
+ {
+ destroy((private_pubkey_cert_t*)this->key);
+ }
+ builder_cancel(&this->public);
}
/**