From: Martin Willi Date: Thu, 5 Aug 2010 11:13:04 +0000 (+0200) Subject: Use certificate subject to get a public key of the TLS server X-Git-Tag: 4.5.0~569 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e85bca7f22199b525e9f5daf488077706888a4e8;p=thirdparty%2Fstrongswan.git Use certificate subject to get a public key of the TLS server --- diff --git a/src/libtls/tls_peer.c b/src/libtls/tls_peer.c index ab4d879203..fd0245cc04 100644 --- a/src/libtls/tls_peer.c +++ b/src/libtls/tls_peer.c @@ -462,6 +462,7 @@ static status_t send_key_exchange(private_tls_peer_t *this, tls_handshake_type_t *type, tls_writer_t *writer) { public_key_t *public = NULL, *current; + certificate_t *cert; enumerator_t *enumerator; auth_cfg_t *auth; rng_t *rng; @@ -482,15 +483,18 @@ static status_t send_key_exchange(private_tls_peer_t *this, chunk_from_thing(this->client_random), chunk_from_thing(this->server_random)); - enumerator = lib->credmgr->create_public_enumerator(lib->credmgr, - KEY_ANY, this->server, this->server_auth); - while (enumerator->enumerate(enumerator, ¤t, &auth)) + cert = this->server_auth->get(this->server_auth, AUTH_HELPER_SUBJECT_CERT); + if (cert) { - public = current->get_ref(current); - break; + enumerator = lib->credmgr->create_public_enumerator(lib->credmgr, + KEY_ANY, cert->get_subject(cert), this->server_auth); + while (enumerator->enumerate(enumerator, ¤t, &auth)) + { + public = current->get_ref(current); + break; + } + enumerator->destroy(enumerator); } - enumerator->destroy(enumerator); - if (!public) { DBG1(DBG_IKE, "no TLS public key found for server '%Y'", this->server);