From c0d0391a5148f1b6cadee84af6c2006b6227ca93 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Wed, 5 Jun 2013 11:30:05 +0200 Subject: [PATCH] pubkey: Improve comparison of raw public key certificate objects --- src/libstrongswan/plugins/pubkey/pubkey_cert.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/libstrongswan/plugins/pubkey/pubkey_cert.c b/src/libstrongswan/plugins/pubkey/pubkey_cert.c index 95f53f919..b7ba5ad43 100644 --- a/src/libstrongswan/plugins/pubkey/pubkey_cert.c +++ b/src/libstrongswan/plugins/pubkey/pubkey_cert.c @@ -110,15 +110,25 @@ METHOD(certificate_t, has_issuer, id_match_t, METHOD(certificate_t, equals, bool, private_pubkey_cert_t *this, certificate_t *other) { + identification_t *other_subject; public_key_t *other_key; + if (this == (private_pubkey_cert_t*)other) + { + return TRUE; + } + if (other->get_type(other) != CERT_TRUSTED_PUBKEY) + { + return FALSE; + } other_key = other->get_public_key(other); if (other_key) { if (public_key_equals(this->key, other_key)) { other_key->destroy(other_key); - return TRUE; + other_subject = other->get_subject(other); + return other_subject->equals(other_subject, this->subject); } other_key->destroy(other_key); }