try to cache the same instance of equal certificates
authorMartin Willi <martin@strongswan.org>
Mon, 7 Apr 2008 08:44:43 +0000 (08:44 -0000)
committerMartin Willi <martin@strongswan.org>
Mon, 7 Apr 2008 08:44:43 +0000 (08:44 -0000)
src/charon/credentials/sets/cert_cache.c

index 188d266..e6c2cf9 100644 (file)
@@ -118,11 +118,24 @@ static bool issued_by(private_cert_cache_t *this,
        enumerator = this->relations->create_enumerator(this->relations);
        while (enumerator->enumerate(enumerator, &current))
        {
-               if (current->subject == subject && current->issuer == issuer)
+               bool match = FALSE;
+       
+               /* check for equal certificates */
+               if (subject->equals(subject, current->subject))
+               {
+                       match = TRUE;
+                       subject = current->subject;
+               }
+               if (issuer->equals(issuer, current->issuer))
                {
-                       current->last_use = time(NULL);
-                       found = current;
-                       break;
+                       issuer = current->issuer;
+                       /* if both certs match, we already have a relation */
+                       if (match)
+                       {
+                               current->last_use = time(NULL);
+                               found = current;
+                               break;
+                       }
                }
        }
        enumerator->destroy(enumerator);