diff options
author | Martin Willi <martin@strongswan.org> | 2008-09-02 11:00:13 +0000 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2008-09-02 11:00:13 +0000 |
commit | f7c17aa15c13b10f7b624ae8da5ea3d921b77535 (patch) | |
tree | e8db73c667aa1c9f0d827ed590aeb6393d6037e3 /src/libstrongswan/plugins/pubkey/pubkey_cert.c | |
parent | 4da0116d78b726ef4125577bed8e9974883fc7fd (diff) | |
download | strongswan-f7c17aa15c13b10f7b624ae8da5ea3d921b77535.tar.bz2 strongswan-f7c17aa15c13b10f7b624ae8da5ea3d921b77535.tar.xz |
refactored credential builder
allow enumeration of matching builders
try a second builder if the first one fails
builder clones resources internally on demand
caller frees added resources on failure and success
stricter handling of non-supported build parts
Diffstat (limited to 'src/libstrongswan/plugins/pubkey/pubkey_cert.c')
-rw-r--r-- | src/libstrongswan/plugins/pubkey/pubkey_cert.c | 33 |
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); } /** |