store multiple extensions in context
authorMarcel Poul <marcel.poul@cern.ch>
Tue, 31 Jan 2012 15:49:22 +0000 (15:49 +0000)
committerMarcel Poul <marcel.poul@cern.ch>
Tue, 31 Jan 2012 15:49:22 +0000 (15:49 +0000)
emi.canl.canl-c/src/canl_cred.c
emi.canl.canl-c/src/canl_cred.h

index 3638398..3216a56 100644 (file)
@@ -48,7 +48,7 @@ canl_cred_free(canl_ctx ctx, canl_cred cred)
         crd->c_cert = NULL;
     }
     if (crd->c_cert_ext) {
-        X509_EXTENSION_free(crd->c_cert_ext);
+        sk_X509_EXTENSION_pop_free(crd->c_cert_ext, X509_EXTENSION_free);
         crd->c_cert_ext = NULL;
     }
     if (crd->c_cert_chain) {
@@ -264,14 +264,11 @@ canl_cred_set_extension(canl_ctx ctx, canl_cred cred, X509_EXTENSION *cert_ext)
 
     if (!cred)
         return set_error(cc, EINVAL, POSIX_ERROR, "Cred. handler"
-                " not initialized" );
-    
-    if (crd->c_cert_ext) {
-        X509_EXTENSION_free(crd->c_cert_ext);
-        crd->c_cert_ext = NULL;
-    }
-    
-    crd->c_cert_ext = X509_EXTENSION_dup(cert_ext);
+                " not initialized" ); 
+
+    if (!crd->c_cert_ext)
+       crd->c_cert_ext = sk_X509_EXTENSION_new_null();
+    sk_X509_EXTENSION_push(crd->c_cert_ext, cert_ext);
     return 0;
 }
 
index 3425518..271af51 100644 (file)
@@ -22,7 +22,7 @@ typedef struct _creds {
     STACK_OF(X509) *c_cert_chain;
     X509 *c_cert;
     long c_lifetime;
-    X509_EXTENSION * c_cert_ext;
+    STACK_OF(X509_EXTENSION) * c_cert_ext;
     canl_cert_type c_type;
     X509_REQ *c_req;
 } creds;