set parsed = TRUE before calling parse_certificate()
authorAndreas Steffen <andreas.steffen@strongswan.org>
Wed, 27 May 2009 07:52:53 +0000 (09:52 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Wed, 27 May 2009 07:52:53 +0000 (09:52 +0200)
src/libstrongswan/plugins/x509/x509_cert.c

index 7462544..75f7f19 100644 (file)
@@ -1176,6 +1176,7 @@ static private_x509_cert_t *create_from_chunk(chunk_t chunk)
        private_x509_cert_t *this = create_empty();
        
        this->encoding = chunk;
+       this->parsed = TRUE;
        if (!parse_certificate(this))
        {
                destroy(this);
@@ -1189,17 +1190,15 @@ static private_x509_cert_t *create_from_chunk(chunk_t chunk)
        }
        
        hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
-       if (hasher != NULL)
-       {
-               hasher->allocate_hash(hasher, this->encoding, &this->encoding_hash);
-               hasher->destroy(hasher);
-       }
-       else
+       if (hasher == NULL)
        {
-               DBG1("  unable to create hash of certificate, SHA1 not supported");             
+               DBG1("  unable to create hash of certificate, SHA1 not supported");     
+               destroy(this);
+               return NULL;    
        }
+       hasher->allocate_hash(hasher, this->encoding, &this->encoding_hash);
+       hasher->destroy(hasher);
        
-       this->parsed = TRUE;
        return this;
 }