aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2015-02-06 13:58:58 +0100
committerMartin Willi <martin@revosec.ch>2015-02-06 13:58:58 +0100
commitb851f0a1051f8c50d5eb4cf45d4f03d96e3f3de4 (patch)
tree34349faec21cdfa347af4e8ed54117f39e4b574e /src
parentc8992ea6d2526b187a2f00c98fe29021c09bdd34 (diff)
downloadstrongswan-b851f0a1051f8c50d5eb4cf45d4f03d96e3f3de4.tar.bz2
strongswan-b851f0a1051f8c50d5eb4cf45d4f03d96e3f3de4.tar.xz
x509: Fix public key reference leak if authority key identifier does not match
Diffstat (limited to 'src')
-rw-r--r--src/libstrongswan/plugins/x509/x509_crl.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/libstrongswan/plugins/x509/x509_crl.c b/src/libstrongswan/plugins/x509/x509_crl.c
index d171ec2c4..1f3f60daa 100644
--- a/src/libstrongswan/plugins/x509/x509_crl.c
+++ b/src/libstrongswan/plugins/x509/x509_crl.c
@@ -462,17 +462,26 @@ METHOD(certificate_t, issued_by, bool,
return FALSE;
}
- /* get the public key of the issuer */
+ scheme = signature_scheme_from_oid(this->algorithm);
+ if (scheme == SIGN_UNKNOWN)
+ {
+ return FALSE;
+ }
key = issuer->get_public_key(issuer);
+ if (!key)
+ {
+ return FALSE;
+ }
/* compare keyIdentifiers if available, otherwise use DNs */
- if (this->authKeyIdentifier.ptr && key)
+ if (this->authKeyIdentifier.ptr)
{
chunk_t fingerprint;
if (!key->get_fingerprint(key, KEYID_PUBKEY_SHA1, &fingerprint) ||
!chunk_equals(fingerprint, this->authKeyIdentifier))
{
+ key->destroy(key);
return FALSE;
}
}
@@ -480,17 +489,10 @@ METHOD(certificate_t, issued_by, bool,
{
if (!this->issuer->equals(this->issuer, issuer->get_subject(issuer)))
{
+ key->destroy(key);
return FALSE;
}
}
-
- /* determine signature scheme */
- scheme = signature_scheme_from_oid(this->algorithm);
-
- if (scheme == SIGN_UNKNOWN || key == NULL)
- {
- return FALSE;
- }
valid = key->verify(key, scheme, this->tbsCertList, this->signature);
key->destroy(key);
if (valid && schemep)