You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by David Reid <da...@jetnet.co.uk> on 2005/02/02 11:17:04 UTC

[PATCH] get a pointer to the raw cert from mod_ssl

Basically this allows us to gain access to the actual cert structure.

Index: ssl_engine_vars.c
===================================================================
--- ssl_engine_vars.c   (revision 123890)
+++ ssl_engine_vars.c   (working copy)
@@ -364,6 +364,10 @@
      else if (strcEQ(var, "CERT")) {
          result = ssl_var_lookup_ssl_cert_PEM(p, xs);
      }
+    else if (strcEQ(var, "RAW_CERT")) {
+        result = (char *)xs;
+        resdup = FALSE;
+    }

      if (result != NULL && resdup)
          result = apr_pstrdup(p, result);

Re: [PATCH] get a pointer to the raw cert from mod_ssl

Posted by David Reid <da...@jetnet.co.uk>.
Joe Orton wrote:

>Here's an alternative implementation: does it work for you?
>
>  
>
I'll try it out tomorrow as time won't permit me to look at it today.

Looks good though.

david

>Index: ssl_private.h
>===================================================================
>--- ssl_private.h	(revision 153210)
>+++ ssl_private.h	(working copy)
>@@ -641,6 +641,9 @@
> /*  Variables  */
> void         ssl_var_register(void);
> char        *ssl_var_lookup(apr_pool_t *, server_rec *, conn_rec *, request_rec *, char *);
>+
>+const char  *ssl_ext_lookup(apr_pool_t *p, conn_rec *c, int peer, const char *oid);
>+
> void         ssl_var_log_config_register(apr_pool_t *p);
> 
> #define APR_SHM_MAXSIZE (64 * 1024 * 1024)
>Index: ssl_engine_vars.c
>===================================================================
>--- ssl_engine_vars.c	(revision 153210)
>+++ ssl_engine_vars.c	(working copy)
>@@ -61,6 +61,7 @@
> {
>     APR_REGISTER_OPTIONAL_FN(ssl_is_https);
>     APR_REGISTER_OPTIONAL_FN(ssl_var_lookup);
>+    APR_REGISTER_OPTIONAL_FN(ssl_ext_lookup);
>     return;
> }
> 
>@@ -655,6 +656,58 @@
>     return result;
> }
> 
>+const char *ssl_ext_lookup(apr_pool_t *p, conn_rec *c, int peer,
>+                           const char *oidnum)
>+{
>+    SSLConnRec *sslconn = myConnConfig(c);
>+    SSL *ssl = sslconn->ssl;
>+    X509 *xs = NULL;
>+    ASN1_OBJECT *oid;
>+    int count = 0, j;
>+    char *result = NULL;
>+    
>+    oid = OBJ_txt2obj(oidnum, 1);
>+    if (!oid) {
>+        ERR_clear_error();
>+        return NULL;
>+    }
>+    
>+    xs = peer ? SSL_get_peer_certificate(ssl) : SSL_get_certificate(ssl);
>+    if (xs == NULL) {
>+        return NULL;
>+    }
>+    
>+    count = X509_get_ext_count(xs);
>+
>+    for (j = 0; j < count; j++) {
>+        X509_EXTENSION *ext = X509_get_ext(xs, j);
>+
>+        if (OBJ_cmp(ext->object, oid) == 0) {
>+            BIO *bio = BIO_new(BIO_s_mem());
>+            BUF_MEM *buf;
>+
>+            if (X509V3_EXT_print(bio, ext, 0, 0) != 1) {
>+                ERR_clear_error();
>+                BIO_vfree(bio);
>+                return NULL;
>+            }
>+            
>+            BIO_get_mem_ptr(bio, &buf);
>+            result = apr_pstrmemdup(p, buf->data, buf->length);
>+            BIO_vfree(bio);
>+            break;
>+        }
>+    }
>+
>+    if (peer) {
>+        /* only SSL_get_peer_certificate raises the refcount */
>+        X509_free(xs);
>+    }
>+
>+    return result;
>+}
>+
>+
> /*  _________________________________________________________________
> **
> **  SSL Extension to mod_log_config
>Index: mod_ssl.h
>===================================================================
>--- mod_ssl.h	(revision 153210)
>+++ mod_ssl.h	(working copy)
>@@ -27,6 +27,16 @@
>                          conn_rec *, request_rec *,
>                          char *));
> 
>+/* The ssl_ext_lookup() optional function retrieves the value of a SSL
>+ * certificate X.509 extension.  The client certificate is used if
>+ * peer is non-zero; the server certificate is used otherwise.  The
>+ * oidnum parameter specifies the numeric OID (e.g. "1.2.3.4") of the
>+ * desired extension.  The string value of the extension is returned,
>+ * or NULL on error. */
>+APR_DECLARE_OPTIONAL_FN(const char *, ssl_ext_lookup,
>+                        (apr_pool_t *p, conn_rec *c, int peer,
>+                         const char *oidnum));
>+
> /* An optional function which returns non-zero if the given connection
>  * is using SSL/TLS. */
> APR_DECLARE_OPTIONAL_FN(int, ssl_is_https, (conn_rec *));
>  
>


Re: [PATCH] get a pointer to the raw cert from mod_ssl

Posted by Joe Orton <jo...@redhat.com>.
On Mon, Feb 14, 2005 at 05:51:50PM +0000, David Reid wrote:
> Joe Orton wrote:
> >Here's an alternative implementation: does it work for you?
> 
> This looks good to me and seems to work as required.

Great!

> Care to commit it?

Now done.

joe

Re: [PATCH] get a pointer to the raw cert from mod_ssl

Posted by David Reid <da...@jetnet.co.uk>.
Joe Orton wrote:
> Here's an alternative implementation: does it work for you?

This looks good to me and seems to work as required.

Care to commit it?

david

> 
> Index: ssl_private.h
> ===================================================================
> --- ssl_private.h	(revision 153210)
> +++ ssl_private.h	(working copy)
> @@ -641,6 +641,9 @@
>  /*  Variables  */
>  void         ssl_var_register(void);
>  char        *ssl_var_lookup(apr_pool_t *, server_rec *, conn_rec *, request_rec *, char *);
> +
> +const char  *ssl_ext_lookup(apr_pool_t *p, conn_rec *c, int peer, const char *oid);
> +
>  void         ssl_var_log_config_register(apr_pool_t *p);
>  
>  #define APR_SHM_MAXSIZE (64 * 1024 * 1024)
> Index: ssl_engine_vars.c
> ===================================================================
> --- ssl_engine_vars.c	(revision 153210)
> +++ ssl_engine_vars.c	(working copy)
> @@ -61,6 +61,7 @@
>  {
>      APR_REGISTER_OPTIONAL_FN(ssl_is_https);
>      APR_REGISTER_OPTIONAL_FN(ssl_var_lookup);
> +    APR_REGISTER_OPTIONAL_FN(ssl_ext_lookup);
>      return;
>  }
>  
> @@ -655,6 +656,58 @@
>      return result;
>  }
>  
> +const char *ssl_ext_lookup(apr_pool_t *p, conn_rec *c, int peer,
> +                           const char *oidnum)
> +{
> +    SSLConnRec *sslconn = myConnConfig(c);
> +    SSL *ssl = sslconn->ssl;
> +    X509 *xs = NULL;
> +    ASN1_OBJECT *oid;
> +    int count = 0, j;
> +    char *result = NULL;
> +    
> +    oid = OBJ_txt2obj(oidnum, 1);
> +    if (!oid) {
> +        ERR_clear_error();
> +        return NULL;
> +    }
> +    
> +    xs = peer ? SSL_get_peer_certificate(ssl) : SSL_get_certificate(ssl);
> +    if (xs == NULL) {
> +        return NULL;
> +    }
> +    
> +    count = X509_get_ext_count(xs);
> +
> +    for (j = 0; j < count; j++) {
> +        X509_EXTENSION *ext = X509_get_ext(xs, j);
> +
> +        if (OBJ_cmp(ext->object, oid) == 0) {
> +            BIO *bio = BIO_new(BIO_s_mem());
> +            BUF_MEM *buf;
> +
> +            if (X509V3_EXT_print(bio, ext, 0, 0) != 1) {
> +                ERR_clear_error();
> +                BIO_vfree(bio);
> +                return NULL;
> +            }
> +            
> +            BIO_get_mem_ptr(bio, &buf);
> +            result = apr_pstrmemdup(p, buf->data, buf->length);
> +            BIO_vfree(bio);
> +            break;
> +        }
> +    }
> +
> +    if (peer) {
> +        /* only SSL_get_peer_certificate raises the refcount */
> +        X509_free(xs);
> +    }
> +
> +    return result;
> +}
> +
> +
>  /*  _________________________________________________________________
>  **
>  **  SSL Extension to mod_log_config
> Index: mod_ssl.h
> ===================================================================
> --- mod_ssl.h	(revision 153210)
> +++ mod_ssl.h	(working copy)
> @@ -27,6 +27,16 @@
>                           conn_rec *, request_rec *,
>                           char *));
>  
> +/* The ssl_ext_lookup() optional function retrieves the value of a SSL
> + * certificate X.509 extension.  The client certificate is used if
> + * peer is non-zero; the server certificate is used otherwise.  The
> + * oidnum parameter specifies the numeric OID (e.g. "1.2.3.4") of the
> + * desired extension.  The string value of the extension is returned,
> + * or NULL on error. */
> +APR_DECLARE_OPTIONAL_FN(const char *, ssl_ext_lookup,
> +                        (apr_pool_t *p, conn_rec *c, int peer,
> +                         const char *oidnum));
> +
>  /* An optional function which returns non-zero if the given connection
>   * is using SSL/TLS. */
>  APR_DECLARE_OPTIONAL_FN(int, ssl_is_https, (conn_rec *));


Re: [PATCH] get a pointer to the raw cert from mod_ssl

Posted by Joe Orton <jo...@redhat.com>.
Here's an alternative implementation: does it work for you?

Index: ssl_private.h
===================================================================
--- ssl_private.h	(revision 153210)
+++ ssl_private.h	(working copy)
@@ -641,6 +641,9 @@
 /*  Variables  */
 void         ssl_var_register(void);
 char        *ssl_var_lookup(apr_pool_t *, server_rec *, conn_rec *, request_rec *, char *);
+
+const char  *ssl_ext_lookup(apr_pool_t *p, conn_rec *c, int peer, const char *oid);
+
 void         ssl_var_log_config_register(apr_pool_t *p);
 
 #define APR_SHM_MAXSIZE (64 * 1024 * 1024)
Index: ssl_engine_vars.c
===================================================================
--- ssl_engine_vars.c	(revision 153210)
+++ ssl_engine_vars.c	(working copy)
@@ -61,6 +61,7 @@
 {
     APR_REGISTER_OPTIONAL_FN(ssl_is_https);
     APR_REGISTER_OPTIONAL_FN(ssl_var_lookup);
+    APR_REGISTER_OPTIONAL_FN(ssl_ext_lookup);
     return;
 }
 
@@ -655,6 +656,58 @@
     return result;
 }
 
+const char *ssl_ext_lookup(apr_pool_t *p, conn_rec *c, int peer,
+                           const char *oidnum)
+{
+    SSLConnRec *sslconn = myConnConfig(c);
+    SSL *ssl = sslconn->ssl;
+    X509 *xs = NULL;
+    ASN1_OBJECT *oid;
+    int count = 0, j;
+    char *result = NULL;
+    
+    oid = OBJ_txt2obj(oidnum, 1);
+    if (!oid) {
+        ERR_clear_error();
+        return NULL;
+    }
+    
+    xs = peer ? SSL_get_peer_certificate(ssl) : SSL_get_certificate(ssl);
+    if (xs == NULL) {
+        return NULL;
+    }
+    
+    count = X509_get_ext_count(xs);
+
+    for (j = 0; j < count; j++) {
+        X509_EXTENSION *ext = X509_get_ext(xs, j);
+
+        if (OBJ_cmp(ext->object, oid) == 0) {
+            BIO *bio = BIO_new(BIO_s_mem());
+            BUF_MEM *buf;
+
+            if (X509V3_EXT_print(bio, ext, 0, 0) != 1) {
+                ERR_clear_error();
+                BIO_vfree(bio);
+                return NULL;
+            }
+            
+            BIO_get_mem_ptr(bio, &buf);
+            result = apr_pstrmemdup(p, buf->data, buf->length);
+            BIO_vfree(bio);
+            break;
+        }
+    }
+
+    if (peer) {
+        /* only SSL_get_peer_certificate raises the refcount */
+        X509_free(xs);
+    }
+
+    return result;
+}
+
+
 /*  _________________________________________________________________
 **
 **  SSL Extension to mod_log_config
Index: mod_ssl.h
===================================================================
--- mod_ssl.h	(revision 153210)
+++ mod_ssl.h	(working copy)
@@ -27,6 +27,16 @@
                          conn_rec *, request_rec *,
                          char *));
 
+/* The ssl_ext_lookup() optional function retrieves the value of a SSL
+ * certificate X.509 extension.  The client certificate is used if
+ * peer is non-zero; the server certificate is used otherwise.  The
+ * oidnum parameter specifies the numeric OID (e.g. "1.2.3.4") of the
+ * desired extension.  The string value of the extension is returned,
+ * or NULL on error. */
+APR_DECLARE_OPTIONAL_FN(const char *, ssl_ext_lookup,
+                        (apr_pool_t *p, conn_rec *c, int peer,
+                         const char *oidnum));
+
 /* An optional function which returns non-zero if the given connection
  * is using SSL/TLS. */
 APR_DECLARE_OPTIONAL_FN(int, ssl_is_https, (conn_rec *));

Re: [PATCH] get a pointer to the raw cert from mod_ssl

Posted by Joe Orton <jo...@redhat.com>.
On Wed, Feb 02, 2005 at 09:08:02PM +0000, David Reid wrote:
> William A. Rowe, Jr. wrote:
> >At 04:17 AM 2/2/2005, David Reid wrote:
> >
> >>Basically this allows us to gain access to the actual cert structure.
> >
> >
> >Agreed that raw cert isn't that useful, and somewhat frightens
> >me in the environment table.  The PEM or DER formats would be 
> >generally useful.  Unpacking the extended X509 attributes
> >might be even more useful.
> >
> >Bill
> >
> >
> This is the patch that provides me with the functionality I need. It's 
> generalised to a high degree and provides an easy way to get access to 
> extension data. It keeps the details hidden within mod_ssl where they 
> belong.

This is better but still: casting the extension value to an ASN1_STRING
is cheating: it is *not* a string.  The value can be converted to a real
well-defined NUL-terminated string by printing it through a memory bio. 
The interface to "only return if value matches given value" is weird and
inflexible; it would be cleaner to either pass in an index integer and
return the Nth extension with the given OID; or to pass in an
apr_array_t and return *all* matching extension values.

It would be much simpler to just OBJ_txt2obj the passed-in oid and
OBJ_cmp that rather than jumping through hoops to always compare oids as
strings.

I can hack up a revised patch to do all this if you like.

joe

Re: [PATCH] get a pointer to the raw cert from mod_ssl

Posted by David Reid <da...@jetnet.co.uk>.
William A. Rowe, Jr. wrote:
> At 04:17 AM 2/2/2005, David Reid wrote:
> 
>>Basically this allows us to gain access to the actual cert structure.
> 
> 
> Agreed that raw cert isn't that useful, and somewhat frightens
> me in the environment table.  The PEM or DER formats would be 
> generally useful.  Unpacking the extended X509 attributes
> might be even more useful.
> 
> Bill
> 
> 
This is the patch that provides me with the functionality I need. It's 
generalised to a high degree and provides an easy way to get access to 
extension data. It keeps the details hidden within mod_ssl where they 
belong.

david


Index: ssl_private.h
===================================================================
--- ssl_private.h       (revision 123890)
+++ ssl_private.h       (working copy)
@@ -633,6 +633,7 @@
  /*  Variables  */
  void         ssl_var_register(void);
  char        *ssl_var_lookup(apr_pool_t *, server_rec *, conn_rec *, 
request_rec *, char *);
+char        *ssl_ext_lookup(apr_pool_t *, conn_rec *, char *, char *);
  void         ssl_var_log_config_register(apr_pool_t *p);

  #define APR_SHM_MAXSIZE (64 * 1024 * 1024)
Index: ssl_engine_vars.c
===================================================================
--- ssl_engine_vars.c   (revision 123890)
+++ ssl_engine_vars.c   (working copy)
@@ -60,6 +60,7 @@
  {
      APR_REGISTER_OPTIONAL_FN(ssl_is_https);
      APR_REGISTER_OPTIONAL_FN(ssl_var_lookup);
+    APR_REGISTER_OPTIONAL_FN(ssl_ext_lookup);
      return;
  }

@@ -654,6 +655,68 @@
      return result;
  }


+/* This function must remain safe to use for a non-SSL connection.
+ * This function is essentially the same as ssl_var_lookup but it looks 
ONLY
+ * in the X509_EXTENSION structures. It looks for a matching OID and 
(optionally)
+ * a value to match.
+ */
+char *ssl_ext_lookup(apr_pool_t *p, conn_rec *c, char *oid, char *var)
+{
+    SSLConnRec *sslconn = myConnConfig(c);
+    char *result = NULL;
+    SSL *ssl = sslconn->ssl;
+    X509 *xs = NULL;
+    int count = 0, j;
+    size_t oidlen, varlen = 0;
+
+    if (!oid)
+        return result;
+
+    oidlen = strlen(oid);
+    if (var)
+        varlen = strlen(var);
+
+    /*
+     * When no pool is given try to find one
+     */
+    if (p == NULL) {
+        if (c != NULL)
+            p = c->pool;
+    }
+    if (!p)

+        return result;
+
+    /* We ONLY operate on peer certificates */
+    if (! (xs = SSL_get_peer_certificate(ssl)))
+        return result;
+
+    if ((count = X509_get_ext_count(xs)) == 0)
+        return result;
+
+    for (j = 0; j < count; j++) {
+        X509_EXTENSION *ext = X509_get_ext(xs, j);
+        char *this_oid = alloca(oidlen + 1);
+        if (OBJ_obj2txt(this_oid, oidlen + 1, ext->object, 1) == oidlen &&
+            strncmp(this_oid, oid, oidlen) == 0) {
+            /* We have found a matching OID.
+             * If we have been asked to match a value, then we check it 
here,
+             * if we've just been asked to find an instance of the OID
+             * then we simply return the value.
+             */
+            char *str = ASN1_STRING_data((ASN1_STRING *)ext->value);
+            if (var) {
+                if (strncmp(str, var, varlen) == 0)
+                    result = apr_pstrdup(p, str);
+            } else
+                result = apr_pstrdup(p, str);
+
+            if (result)
+                break;
+        }
+    }
+    return result;
+}
+
  /*  _________________________________________________________________
  **
  **  SSL Extension to mod_log_config

Index: mod_ssl.h
===================================================================
--- mod_ssl.h   (revision 123890)
+++ mod_ssl.h   (working copy)
@@ -26,6 +26,11 @@
                           conn_rec *, request_rec *,
                           char *));

+/* The ssl_ext_lookup() optional function retrieves SSL environment
+ * variables. */
+APR_DECLARE_OPTIONAL_FN(char *, ssl_ext_lookup,
+                        (apr_pool_t *, conn_rec *, char *, char *));
+
  /* An optional function which returns non-zero if the given connection
   * is using SSL/TLS. */
  APR_DECLARE_OPTIONAL_FN(int, ssl_is_https, (conn_rec *));


Re: [PATCH] get a pointer to the raw cert from mod_ssl

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
At 04:17 AM 2/2/2005, David Reid wrote:
>Basically this allows us to gain access to the actual cert structure.

Agreed that raw cert isn't that useful, and somewhat frightens
me in the environment table.  The PEM or DER formats would be 
generally useful.  Unpacking the extended X509 attributes
might be even more useful.

Bill



Re: [PATCH] get a pointer to the raw cert from mod_ssl

Posted by Joe Orton <jo...@redhat.com>.
On Wed, Feb 02, 2005 at 11:36:41AM +0000, Ben Laurie wrote:
> Joe Orton wrote:
> >On Wed, Feb 02, 2005 at 11:09:47AM +0000, David Reid wrote:
> >>The issue is a need to get access to the internals of the structure.
> >
> >
> >By exposing the X509 * directly you expose a dependency on the
> >underlying SSL toolkit.  What if mod_ssl was built to use the RSA
> >toolkit; will the X509 * have the same fields and layout?  That's why
> >it's preferable to just expose the DER: there's nothing you can't do
> >with the DER that you can do with the X509 * anyway.
> 
> This is a somewhat frivolous point though. If you expose the DER, then 
> the module will have to have some crypto toolkit to understand it. If 
> its a different one from the one mod_ssl is using, then it can always 
> convert to DER and into its own format, using the same kit mod_ssl uses 
> for the first step. So, it seems to me that this is simply making work 
> for modules to no real gain.

That all presumes that random third-party modules can determine which
type of SSL toolkit mod_ssl was built with and where the headers are
etc, which isn't the case.

> Certainly it should only be exported in this format if OpenSSL is in use.
> 
> BTW, I'd advocate using a hook that was typesafe!

Exactly my point: you can't do that without exposing OpenSSL headers
through mod_ssl.h and making the hook declaration conditional on SSL
support being enabled and all that mess.

joe

Re: [PATCH] get a pointer to the raw cert from mod_ssl

Posted by Ben Laurie <be...@algroup.co.uk>.
Joe Orton wrote:
> On Wed, Feb 02, 2005 at 11:09:47AM +0000, David Reid wrote:
> 
>>Joe Orton wrote:
>>
>>>On Wed, Feb 02, 2005 at 10:17:04AM +0000, David Reid wrote:
>>>
>>>
>>>>Basically this allows us to gain access to the actual cert structure.
>>>
>>>
>>>I don't like the idea of exposing the X509 * directly especially not
>>>through a char * interface.  Exposing the DER representation (e.g.
>>>base64-encoded) through ssl_var_lookup would be better.
> 
> 
> (of course that's essentially what _CERT_PEM is; but exporting it
> without the unnecessary PEM trimmings is useful too)
> 
> 
>>The issue is a need to get access to the internals of the structure.
> 
> 
> By exposing the X509 * directly you expose a dependency on the
> underlying SSL toolkit.  What if mod_ssl was built to use the RSA
> toolkit; will the X509 * have the same fields and layout?  That's why
> it's preferable to just expose the DER: there's nothing you can't do
> with the DER that you can do with the X509 * anyway.

This is a somewhat frivolous point though. If you expose the DER, then 
the module will have to have some crypto toolkit to understand it. If 
its a different one from the one mod_ssl is using, then it can always 
convert to DER and into its own format, using the same kit mod_ssl uses 
for the first step. So, it seems to me that this is simply making work 
for modules to no real gain.

Certainly it should only be exported in this format if OpenSSL is in use.

BTW, I'd advocate using a hook that was typesafe!

Cheers,

Ben.


-- 
http://www.apache-ssl.org/ben.html       http://www.thebunker.net/

"There is no limit to what a man can do or how far he can go if he
doesn't mind who gets the credit." - Robert Woodruff

Re: [PATCH] get a pointer to the raw cert from mod_ssl

Posted by Joe Orton <jo...@redhat.com>.
On Wed, Feb 02, 2005 at 11:09:47AM +0000, David Reid wrote:
> Joe Orton wrote:
> >On Wed, Feb 02, 2005 at 10:17:04AM +0000, David Reid wrote:
> >
> >>Basically this allows us to gain access to the actual cert structure.
> >
> >
> >I don't like the idea of exposing the X509 * directly especially not
> >through a char * interface.  Exposing the DER representation (e.g.
> >base64-encoded) through ssl_var_lookup would be better.

(of course that's essentially what _CERT_PEM is; but exporting it
without the unnecessary PEM trimmings is useful too)

> The issue is a need to get access to the internals of the structure.

By exposing the X509 * directly you expose a dependency on the
underlying SSL toolkit.  What if mod_ssl was built to use the RSA
toolkit; will the X509 * have the same fields and layout?  That's why
it's preferable to just expose the DER: there's nothing you can't do
with the DER that you can do with the X509 * anyway.

joe

Re: [PATCH] get a pointer to the raw cert from mod_ssl

Posted by David Reid <da...@jetnet.co.uk>.
Joe Orton wrote:
> On Wed, Feb 02, 2005 at 10:17:04AM +0000, David Reid wrote:
> 
>>Basically this allows us to gain access to the actual cert structure.
> 
> 
> I don't like the idea of exposing the X509 * directly especially not
> through a char * interface.  Exposing the DER representation (e.g.
> base64-encoded) through ssl_var_lookup would be better.

The issue is a need to get access to the internals of the structure.

The existing function doesn't meet the requirements, but I'll work up an 
alternative patch to add a new function that will meet them.

david


> joe
> 
> 
> 
>>Index: ssl_engine_vars.c
>>===================================================================
>>--- ssl_engine_vars.c   (revision 123890)
>>+++ ssl_engine_vars.c   (working copy)
>>@@ -364,6 +364,10 @@
>>     else if (strcEQ(var, "CERT")) {
>>         result = ssl_var_lookup_ssl_cert_PEM(p, xs);
>>     }
>>+    else if (strcEQ(var, "RAW_CERT")) {
>>+        result = (char *)xs;
>>+        resdup = FALSE;
>>+    }
>>
>>     if (result != NULL && resdup)
>>         result = apr_pstrdup(p, result);


Re: [PATCH] get a pointer to the raw cert from mod_ssl

Posted by Joe Orton <jo...@redhat.com>.
On Wed, Feb 02, 2005 at 10:17:04AM +0000, David Reid wrote:
> Basically this allows us to gain access to the actual cert structure.

I don't like the idea of exposing the X509 * directly especially not
through a char * interface.  Exposing the DER representation (e.g.
base64-encoded) through ssl_var_lookup would be better.

joe


> Index: ssl_engine_vars.c
> ===================================================================
> --- ssl_engine_vars.c   (revision 123890)
> +++ ssl_engine_vars.c   (working copy)
> @@ -364,6 +364,10 @@
>      else if (strcEQ(var, "CERT")) {
>          result = ssl_var_lookup_ssl_cert_PEM(p, xs);
>      }
> +    else if (strcEQ(var, "RAW_CERT")) {
> +        result = (char *)xs;
> +        resdup = FALSE;
> +    }
> 
>      if (result != NULL && resdup)
>          result = apr_pstrdup(p, result);