From: Andreas Steffen Date: Sun, 11 Oct 2009 19:14:05 +0000 (+0200) Subject: fixed broken smartcard support (bug #91) X-Git-Tag: 4.3.5rc1~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8e2a147db86300d643aeaed8f2eecb8f297b67a;p=thirdparty%2Fstrongswan.git fixed broken smartcard support (bug #91) --- diff --git a/src/pluto/ike_alg.c b/src/pluto/ike_alg.c index 5d26a958d7..3528a62efb 100644 --- a/src/pluto/ike_alg.c +++ b/src/pluto/ike_alg.c @@ -23,6 +23,8 @@ #include #include +#include +#include #include #include #include @@ -193,20 +195,42 @@ struct db_context *ike_alg_db_new(connection_t *c, lset_t policy) if (policy & POLICY_PUBKEY) { int auth_method = 0; - private_key_t *key = get_private_key(c); + size_t key_size = 0; + key_type_t key_type = KEY_ANY; - if (key == NULL) + + if (c->spd.this.cert.type != CERT_NONE) + { + public_key_t *key = cert_get_public_key(c->spd.this.cert); + + if (key == NULL) + { + plog("ike alg: unable to retrieve my public key"); + continue; + } + key_type = key->get_type(key); + key_size = key->get_keysize(key); + key->destroy(key); + } + else { - plog("ike alg: unable to locate my private key"); - continue; + private_key_t *key = get_private_key(c); + + if (key == NULL) + { + plog("ike alg: unable to retrieve my private key"); + continue; + } + key_type = key->get_type(key); + key_size = key->get_keysize(key); } - switch (key->get_type(key)) + switch (key_type) { case KEY_RSA: auth_method = OAKLEY_RSA_SIG; break; case KEY_ECDSA: - switch (key->get_keysize(key)) + switch (key_size) { case 32: auth_method = OAKLEY_ECDSA_256;