From dd57ae05c6851b1e8bace9e03000f46e40b1650f Mon Sep 17 00:00:00 2001 From: Marcel Poul Date: Tue, 31 Jan 2012 15:49:22 +0000 Subject: [PATCH] store multiple extensions in context --- emi.canl.canl-c/src/canl_cred.c | 15 ++++++--------- emi.canl.canl-c/src/canl_cred.h | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/emi.canl.canl-c/src/canl_cred.c b/emi.canl.canl-c/src/canl_cred.c index 3638398..3216a56 100644 --- a/emi.canl.canl-c/src/canl_cred.c +++ b/emi.canl.canl-c/src/canl_cred.c @@ -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; } diff --git a/emi.canl.canl-c/src/canl_cred.h b/emi.canl.canl-c/src/canl_cred.h index 3425518..271af51 100644 --- a/emi.canl.canl-c/src/canl_cred.h +++ b/emi.canl.canl-c/src/canl_cred.h @@ -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; -- 1.8.2.3