Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Apache: Dev

Re: svn commit: r829619 - in /httpd/httpd/trunk: ./ modules/ssl/

 

 

Apache dev RSS feed   Index | Next | Previous | View Threaded


rpluem at apache

Oct 25, 2009, 4:44 PM

Post #1 of 16 (362 views)
Permalink
Re: svn commit: r829619 - in /httpd/httpd/trunk: ./ modules/ssl/

On 10/25/2009 06:21 PM, jorton[at]apache.org wrote:
> Author: jorton
> Date: Sun Oct 25 17:21:10 2009
> New Revision: 829619
>
> URL: http://svn.apache.org/viewvc?rev=829619&view=rev
> Log:
> Add support for OCSP "stapling":
>
> * modules/ssl/ssl_util_stapling.c: New file.
>
> * modules/ssl/config.m4, modules/ssl/mod_ssl.dsp: Build it.
>
> * modules/ssl/ssl_toolkit_compat.h: Define HAVE_OCSP_STAPLING if
> OpenSSL is of suitable version (>= 0.9.8g) and capability (TLS
> extension support enabled).
>
> * modules/ssl/mod_ssl.c: Add config directives.
>
> * modules/ssl/ssl_private.h: Add prototypes for new functions.
> (SSLModConfigRec): Add fields for stapling socache instance and
> associated mutex.
> (modssl_ctx_t): Add config fields for stapling.
>
> * modules/ssl/ssl_engine_init.c (ssl_init_Module, ssl_init_Child):
> Call the stapling initialization functions.
>
> * modules/ssl/ssl_engine_config.c: Add config hooks.
>
> * modules/ssl/ssl_scache.c: Create, initialize and destroy the socache
> instance for OCSP responses.
>
> Submitted by: Dr Stephen Henson <shenson oss-institute.org>

Will there be documentation patches for the new directives?

>
> Added:
> httpd/httpd/trunk/modules/ssl/ssl_util_stapling.c
> Modified:
> httpd/httpd/trunk/CHANGES
> httpd/httpd/trunk/modules/ssl/config.m4
> httpd/httpd/trunk/modules/ssl/mod_ssl.c
> httpd/httpd/trunk/modules/ssl/mod_ssl.dsp
> httpd/httpd/trunk/modules/ssl/ssl_engine_config.c
> httpd/httpd/trunk/modules/ssl/ssl_engine_init.c
> httpd/httpd/trunk/modules/ssl/ssl_private.h
> httpd/httpd/trunk/modules/ssl/ssl_scache.c
> httpd/httpd/trunk/modules/ssl/ssl_toolkit_compat.h
>

> Added: httpd/httpd/trunk/modules/ssl/ssl_util_stapling.c
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ssl/ssl_util_stapling.c?rev=829619&view=auto
> ==============================================================================
> --- httpd/httpd/trunk/modules/ssl/ssl_util_stapling.c (added)
> +++ httpd/httpd/trunk/modules/ssl/ssl_util_stapling.c Sun Oct 25 17:21:10 2009

> +/*
> + * OCSP response caching code. The response is preceded by a flag value
> + * which indicates whether the response was invalid when it was stored.
> + * the purpose of this flag is to avoid repeated queries to a server
> + * which has given an invalid response while allowing a response which
> + * has subsequently become invalid to be retried immediately.
> + *
> + * The key for the cache is the hash of the certificate the response
> + * is for.
> + */
> +static BOOL stapling_cache_response(server_rec *s, modssl_ctx_t *mctx,
> + OCSP_RESPONSE *rsp, certinfo *cinf,
> + BOOL ok, apr_pool_t *pool)
> +{
> + SSLModConfigRec *mc = myModConfig(s);
> + unsigned char resp_der[MAX_STAPLING_DER];
> + unsigned char *p;
> + int resp_derlen;
> + BOOL rv;
> + time_t timeout;
> +
> + resp_derlen = i2d_OCSP_RESPONSE(rsp, NULL) + 1;
> +
> + if (resp_derlen <= 0) {
> + ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
> + "OCSP stapling response encode error??");
> + return FALSE;
> + }
> +
> + if (resp_derlen > sizeof resp_der) {
> + ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
> + "OCSP stapling response too big (%u bytes)", resp_derlen);
> + return FALSE;
> + }
> +
> +
> + p = resp_der;
> +
> + if (ok == TRUE) {
> + *p++ = 1;
> + timeout = mctx->stapling_cache_timeout;
> + } else {
> + *p++ = 0;
> + timeout = mctx->stapling_errcache_timeout;
> + }
> +
> + timeout += time(NULL);

Shouldn't we use apr_time_now here?

> +
> + i2d_OCSP_RESPONSE(rsp, &p);

Is this correct? p is already char *. So &p would be char **.
If p gets changed by i2d_OCSP_RESPONSE our flag set above would get lost ???

> +
> + rv = mc->stapling_cache->store(mc->stapling_cache_context, s,
> + cinf->idx, sizeof(cinf->idx),
> + timeout, resp_der, resp_derlen, pool);
> + if (rv != APR_SUCCESS) {
> + ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
> + "stapling_cache_response: OCSP response session store error!");
> + return FALSE;
> + }
> +
> + return TRUE;
> +}
> +
> +static BOOL stapling_get_cached_response(server_rec *s, OCSP_RESPONSE **prsp,
> + BOOL *pok, certinfo *cinf,
> + apr_pool_t *pool)
> +{
> + SSLModConfigRec *mc = myModConfig(s);
> + apr_status_t rv;
> + OCSP_RESPONSE *rsp;
> + unsigned char resp_der[MAX_STAPLING_DER];
> + const unsigned char *p;
> + unsigned int resp_derlen = MAX_STAPLING_DER;
> +
> + rv = mc->stapling_cache->retrieve(mc->stapling_cache_context, s,
> + cinf->idx, sizeof(cinf->idx),
> + resp_der, &resp_derlen, pool);
> + if (rv != APR_SUCCESS) {
> + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
> + "stapling_get_cached_response: cache miss");
> + return TRUE;
> + }
> + if (resp_derlen <= 1) {
> + ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
> + "stapling_get_cached_response: response length invalid??");
> + return TRUE;
> + }
> + p = resp_der;
> + if (pok) {
> + if (*p)
> + *pok = TRUE;
> + else
> + *pok = FALSE;
> + }
> + p++;
> + resp_derlen--;
> + rsp = d2i_OCSP_RESPONSE(NULL, &p, resp_derlen);

Why &p and not p?

> + if (!rsp) {
> + ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
> + "stapling_get_cached_response: response parse error??");
> + return TRUE;
> + }
> + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
> + "stapling_get_cached_response: cache hit");
> +
> + *prsp = rsp;
> +
> + return TRUE;
> +}
> +

> +static BOOL stapling_renew_response(server_rec *s, modssl_ctx_t *mctx, SSL *ssl,
> + certinfo *cinf, OCSP_RESPONSE **prsp,
> + apr_pool_t *pool)
> +{
> + conn_rec *conn = (conn_rec *)SSL_get_app_data(ssl);
> + apr_pool_t *vpool;
> + OCSP_REQUEST *req = NULL;
> + OCSP_CERTID *id = NULL;
> + STACK_OF(X509_EXTENSION) *exts;
> + int i;
> + BOOL ok = FALSE;
> + BOOL rv = TRUE;
> + const char *ocspuri;
> + apr_uri_t uri;
> +
> + *prsp = NULL;
> + /* Build up OCSP query from server certificate info */
> + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
> + "stapling_renew_response: querying responder");
> +
> + req = OCSP_REQUEST_new();
> + if (!req)
> + goto err;
> + id = OCSP_CERTID_dup(cinf->cid);
> + if (!id)
> + goto err;
> + if (!OCSP_request_add0_id(req, id))
> + goto err;
> + id = NULL;
> + /* Add any extensions to the request */
> + SSL_get_tlsext_status_exts(ssl, &exts);
> + for (i = 0; i < sk_X509_EXTENSION_num(exts); i++) {
> + X509_EXTENSION *ext = sk_X509_EXTENSION_value(exts, i);
> + if (!OCSP_REQUEST_add_ext(req, ext, -1))
> + goto err;
> + }
> +
> + if (mctx->stapling_force_url)
> + ocspuri = mctx->stapling_force_url;
> + else
> + ocspuri = cinf->uri;
> +
> + /* Create a temporary pool to constrain memory use */
> + apr_pool_create(&vpool, conn->pool);
> +
> + ok = apr_uri_parse(vpool, ocspuri, &uri);
> + if (ok != APR_SUCCESS) {
> + ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
> + "stapling_renew_response: Error parsing uri %s",
> + ocspuri);
> + rv = FALSE;
> + goto done;

I guess we are missing some indention here.

> + } else if (strcmp(uri.scheme, "http")) {
> + ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
> + "stapling_renew_response: Unsupported uri %s", ocspuri);
> + rv = FALSE;
> + goto done;

I guess we are missing some indention here.

> + }
> +
> + *prsp = modssl_dispatch_ocsp_request(&uri, mctx->stapling_responder_timeout,
> + req, conn, vpool);
> +
> + apr_pool_destroy(vpool);
> +
> + if (!*prsp) {
> + ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
> + "stapling_renew_response: responder error");
> + if (mctx->stapling_fake_trylater) {
> + *prsp = OCSP_response_create(OCSP_RESPONSE_STATUS_TRYLATER, NULL);
> + }
> + else {
> + goto done;
> + }
> + } else {
> + int response_status = OCSP_response_status(*prsp);
> +
> + if (response_status == OCSP_RESPONSE_STATUS_SUCCESSFUL) {
> + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
> + "stapling_renew_response: query response received");
> + stapling_check_response(s, mctx, cinf, *prsp, &ok);
> + if (ok == FALSE) {
> + ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
> + "stapling_renew_response: error in retreived response!");
> + }
> + } else {
> + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
> + "stapling_renew_response: responder error %s",
> + OCSP_response_status_str(response_status));
> + }
> + }
> + if (stapling_cache_response(s, mctx, *prsp, cinf, ok, pool) == FALSE) {
> + ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
> + "stapling_renew_response: error caching response!");
> + }
> +
> +done:
> + if (id)
> + OCSP_CERTID_free(id);
> + if (req)
> + OCSP_REQUEST_free(req);
> + return rv;
> +err:
> + rv = FALSE;
> + goto done;

Looks a little bit like spaghetti code :-).

> +}
> +

> +/* Certificate Status callback. This is called when a client includes a
> + * certificate status request extension.
> + *
> + * Check for cached responses in session cache. If valid send back to
> + * client. If absent or no longer valid query responder and update
> + * cache. */
> +static int stapling_cb(SSL *ssl, void *arg)
> +{
> + conn_rec *conn = (conn_rec *)SSL_get_app_data(ssl);
> + server_rec *s = conn->base_server;

Shouldn't we use mySrvFromConn(conn) here instead of conn->base_server?

> +
> + SSLSrvConfigRec *sc = mySrvConfig(s);
> + SSLConnRec *sslconn = myConnConfig(conn);
> + modssl_ctx_t *mctx = myCtxConfig(sslconn, sc);
> + certinfo *cinf = NULL;
> + OCSP_RESPONSE *rsp = NULL;
> + int rv;
> + BOOL ok;
> +
> + if (sc->server->stapling_enabled != TRUE) {
> + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
> + "stapling_cb: OCSP Stapling disabled");
> + return SSL_TLSEXT_ERR_NOACK;
> + }
> +
> + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
> + "stapling_cb: OCSP Stapling callback called");
> +
> + cinf = stapling_get_cert_info(s, mctx, ssl);
> + if (cinf == NULL) {
> + return SSL_TLSEXT_ERR_NOACK;
> + }
> +
> + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
> + "stapling_cb: retrieved cached certificate data");
> +
> + /* Check to see if we already have a response for this certificate */
> + stapling_mutex_on(s);
> +
> + rv = stapling_get_cached_response(s, &rsp, &ok, cinf, conn->pool);
> + if (rv == FALSE) {
> + stapling_mutex_off(s);
> + return SSL_TLSEXT_ERR_ALERT_FATAL;
> + }
> +
> + if (rsp) {
> + /* see if response is acceptable */
> + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
> + "stapling_cb: retrieved cached response");
> + rv = stapling_check_response(s, mctx, cinf, rsp, NULL);
> + if (rv == SSL_TLSEXT_ERR_ALERT_FATAL) {
> + OCSP_RESPONSE_free(rsp);
> + stapling_mutex_off(s);
> + return SSL_TLSEXT_ERR_ALERT_FATAL;
> + }
> + else if (rv == SSL_TLSEXT_ERR_NOACK) {
> + /* Error in response. If this error was not present when it was
> + * stored (i.e. response no longer valid) then it can be
> + * renewed straight away.
> + *
> + * If the error *was* present at the time it was stored then we
> + * don't renew the response straight away we just wait for the
> + * cached response to expire.
> + */
> + if (ok) {
> + OCSP_RESPONSE_free(rsp);
> + rsp = NULL;
> + }
> + else if (!mctx->stapling_return_errors) {
> + OCSP_RESPONSE_free(rsp);
> + stapling_mutex_off(s);
> + return SSL_TLSEXT_ERR_NOACK;
> + }
> + }
> + }
> +
> + if (rsp == NULL) {
> + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
> + "stapling_cb: renewing cached response");
> + rv = stapling_renew_response(s, mctx, ssl, cinf, &rsp, conn->pool);
> +
> + if (rv == FALSE) {
> + stapling_mutex_off(s);
> + ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
> + "stapling_cb: fatal error");
> + return SSL_TLSEXT_ERR_ALERT_FATAL;
> + }
> + }
> + stapling_mutex_off(s);
> +
> + if (rsp) {
> + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
> + "stapling_cb: setting response");
> + if (!stapling_set_response(ssl, rsp))
> + return SSL_TLSEXT_ERR_ALERT_FATAL;
> + return SSL_TLSEXT_ERR_OK;
> + }
> + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
> + "stapling_cb: no response available");
> +
> + return SSL_TLSEXT_ERR_NOACK;
> +
> +}
> +


Regards

Rüdiger


poirier at pobox

Oct 26, 2009, 5:37 AM

Post #2 of 16 (345 views)
Permalink
Re: svn commit: r829619 - in /httpd/httpd/trunk: ./ modules/ssl/ [In reply to]

jorton[at]apache.org writes:

> Author: jorton
> Date: Sun Oct 25 17:21:10 2009
> New Revision: 829619
...
> +const char *ssl_cmd_SSLStaplingResponseTimeSkew(cmd_parms *cmd, void *dcfg,
> + const char *arg)
> +{
> + SSLSrvConfigRec *sc = mySrvConfig(cmd->server);
> + sc->server->stapling_resptime_skew = atoi(arg);
> + if (sc->server->stapling_resptime_skew < 0) {
> + return "SSLstapling_resptime_skew: invalid argument";
> + }
> + return NULL;
> +}
> +
> +const char *ssl_cmd_SSLStaplingResponseMaxAge(cmd_parms *cmd, void *dcfg,
> + const char *arg)
> +{
> + SSLSrvConfigRec *sc = mySrvConfig(cmd->server);
> + sc->server->stapling_resp_maxage = atoi(arg);
> + if (sc->server->stapling_resp_maxage < 0) {
> + return "SSLstapling_resp_maxage: invalid argument";
> + }
> + return NULL;
> +}
> +
> +const char *ssl_cmd_SSLStaplingStandardCacheTimeout(cmd_parms *cmd, void *dcfg,
> + const char *arg)
> +{
> + SSLSrvConfigRec *sc = mySrvConfig(cmd->server);
> + sc->server->stapling_cache_timeout = atoi(arg);
> + if (sc->server->stapling_cache_timeout < 0) {
> + return "SSLstapling_cache_timeout: invalid argument";
> + }
> + return NULL;
> +}
> +
> +const char *ssl_cmd_SSLStaplingErrorCacheTimeout(cmd_parms *cmd, void *dcfg,
> + const char *arg)
> +{
> + SSLSrvConfigRec *sc = mySrvConfig(cmd->server);
> + sc->server->stapling_errcache_timeout = atoi(arg);
> + if (sc->server->stapling_errcache_timeout < 0) {
> + return "SSLstapling_errcache_timeout: invalid argument";
> + }
> + return NULL;
> +}
...
> +const char *ssl_cmd_SSLStaplingResponderTimeout(cmd_parms *cmd, void *dcfg,
> + const char *arg)
> +{
> + SSLSrvConfigRec *sc = mySrvConfig(cmd->server);
> + sc->server->stapling_responder_timeout = atoi(arg);
> + sc->server->stapling_responder_timeout *= APR_USEC_PER_SEC;
> + if (sc->server->stapling_responder_timeout < 0) {
> + return "SSLstapling_responder_timeout: invalid argument";
> + }
> + return NULL;
> +}

Shouldn't we check these arguments for validity before using them,
rather than after?

Dan


rpluem at apache

Oct 26, 2009, 7:40 AM

Post #3 of 16 (344 views)
Permalink
Re: svn commit: r829619 - in /httpd/httpd/trunk: ./ modules/ssl/ [In reply to]

On 10/26/2009 01:37 PM, Dan Poirier wrote:
> jorton[at]apache.org writes:
>
>> Author: jorton
>> Date: Sun Oct 25 17:21:10 2009
>> New Revision: 829619
> ...
>> +const char *ssl_cmd_SSLStaplingResponseTimeSkew(cmd_parms *cmd, void *dcfg,
>> + const char *arg)
>> +{
>> + SSLSrvConfigRec *sc = mySrvConfig(cmd->server);
>> + sc->server->stapling_resptime_skew = atoi(arg);
>> + if (sc->server->stapling_resptime_skew < 0) {
>> + return "SSLstapling_resptime_skew: invalid argument";
>> + }
>> + return NULL;
>> +}
>> +
>> +const char *ssl_cmd_SSLStaplingResponseMaxAge(cmd_parms *cmd, void *dcfg,
>> + const char *arg)
>> +{
>> + SSLSrvConfigRec *sc = mySrvConfig(cmd->server);
>> + sc->server->stapling_resp_maxage = atoi(arg);
>> + if (sc->server->stapling_resp_maxage < 0) {
>> + return "SSLstapling_resp_maxage: invalid argument";
>> + }
>> + return NULL;
>> +}
>> +
>> +const char *ssl_cmd_SSLStaplingStandardCacheTimeout(cmd_parms *cmd, void *dcfg,
>> + const char *arg)
>> +{
>> + SSLSrvConfigRec *sc = mySrvConfig(cmd->server);
>> + sc->server->stapling_cache_timeout = atoi(arg);
>> + if (sc->server->stapling_cache_timeout < 0) {
>> + return "SSLstapling_cache_timeout: invalid argument";
>> + }
>> + return NULL;
>> +}
>> +
>> +const char *ssl_cmd_SSLStaplingErrorCacheTimeout(cmd_parms *cmd, void *dcfg,
>> + const char *arg)
>> +{
>> + SSLSrvConfigRec *sc = mySrvConfig(cmd->server);
>> + sc->server->stapling_errcache_timeout = atoi(arg);
>> + if (sc->server->stapling_errcache_timeout < 0) {
>> + return "SSLstapling_errcache_timeout: invalid argument";
>> + }
>> + return NULL;
>> +}
> ...
>> +const char *ssl_cmd_SSLStaplingResponderTimeout(cmd_parms *cmd, void *dcfg,
>> + const char *arg)
>> +{
>> + SSLSrvConfigRec *sc = mySrvConfig(cmd->server);
>> + sc->server->stapling_responder_timeout = atoi(arg);
>> + sc->server->stapling_responder_timeout *= APR_USEC_PER_SEC;
>> + if (sc->server->stapling_responder_timeout < 0) {
>> + return "SSLstapling_responder_timeout: invalid argument";
>> + }
>> + return NULL;
>> +}
>
> Shouldn't we check these arguments for validity before using them,
> rather than after?

Where do we use them so far?
The are the functions to process the directives.

Regards

Rüdiger


poirier at pobox

Oct 26, 2009, 10:54 AM

Post #4 of 16 (342 views)
Permalink
Re: svn commit: r829619 - in /httpd/httpd/trunk: ./ modules/ssl/ [In reply to]

Ruediger Pluem <rpluem[at]apache.org> writes:

> On 10/26/2009 01:37 PM, Dan Poirier wrote:
>> jorton[at]apache.org writes:
>>
>>> Author: jorton
>>> Date: Sun Oct 25 17:21:10 2009
>>> New Revision: 829619
>> ...
>>> +const char *ssl_cmd_SSLStaplingResponseTimeSkew(cmd_parms *cmd, void *dcfg,
>>> + const char *arg)
>>> +{
>>> + SSLSrvConfigRec *sc = mySrvConfig(cmd->server);
>>> + sc->server->stapling_resptime_skew = atoi(arg);
>>> + if (sc->server->stapling_resptime_skew < 0) {
>>> + return "SSLstapling_resptime_skew: invalid argument";
>>> + }
>>> + return NULL;
>>> +}
>>
>> Shouldn't we check these arguments for validity before using them,
>> rather than after?
>
> Where do we use them so far?
> The are the functions to process the directives.

I meant that we assign a new value to the configuration before we know
whether that new value is valid.

It now occurs to me that while the code in isolation looks suspicious,
returning an error means the server won't start, so the point is moot.
Never mind.

Dan


fuankg at apache

Oct 26, 2009, 7:14 PM

Post #5 of 16 (335 views)
Permalink
Re: svn commit: r829619 - in /httpd/httpd/trunk: ./ modules/ssl/ [In reply to]

Hi Joe, Steve,
I have some probs with getting this compiled;
first its inclear for me from where HAVE_OCSP should get defined in
ssl_toolkit.compat.h - for me it seems its not defined in line 42, thus
#include <openssl/ocsp.h>
in line 44 is not included, and causes compile errors on NetWare since
later on in line 150 we have:
#if (OPENSSL_VERSION_NUMBER >= 0x00908080)
#ifndef OPENSSL_NO_TLSEXT
#define HAVE_OCSP_STAPLING
#endif
#endif
so HAVE_OCSP_STAPLING gets defined when !OPENSSL_NO_TLSEXT although
ocsp.h was not included.

After I defined HAVE_OCSP manually with CFLAGS I come to next error in
line 110 of ssl_utl_stapling.c where STACK is not defined; I've searched
both OpenSSL 0.9.8 and 1.0.0 branches, but couldnt find anything but
only _STACK in crypto/stack/stack.h with the hint:
/* Use STACK_OF(...) instead */
so shouldnt line 110 be:
Index: ssl_util_stapling.c
===================================================================
--- ssl_util_stapling.c (revision 830045)
+++ ssl_util_stapling.c (working copy)
@@ -107,7 +107,7 @@
{
certinfo *cinf;
X509 *issuer = NULL;
- STACK *aia = NULL;
+ STACK_OF(OPENSSL_STRING) *aia = NULL;

if (x == NULL)
return 0;

Gün.


shenson at oss-institute

Oct 26, 2009, 7:50 PM

Post #6 of 16 (336 views)
Permalink
Re: svn commit: r829619 - in /httpd/httpd/trunk: ./ modules/ssl/ [In reply to]

Guenter Knauf wrote:
>
> After I defined HAVE_OCSP manually with CFLAGS I come to next error in
> line 110 of ssl_utl_stapling.c where STACK is not defined; I've searched
> both OpenSSL 0.9.8 and 1.0.0 branches, but couldnt find anything but
> only _STACK in crypto/stack/stack.h with the hint:
> /* Use STACK_OF(...) instead */
> so shouldnt line 110 be:
> Index: ssl_util_stapling.c
> ===================================================================
> --- ssl_util_stapling.c (revision 830045)
> +++ ssl_util_stapling.c (working copy)
> @@ -107,7 +107,7 @@
> {
> certinfo *cinf;
> X509 *issuer = NULL;
> - STACK *aia = NULL;
> + STACK_OF(OPENSSL_STRING) *aia = NULL;
>
> if (x == NULL)
> return 0;
>

Erk, shows how long it was since I wrote that. OPENSSL_STRING is only defined in
1.0.0. It should work with STACK in 0.9.8 though: that is defined in
crypto/stack/stack.h I'll work on a fix for both branches.

Steve.
--
Dr Stephen N. Henson. Senior Technical/Cryptography Advisor,
Open Source Software Institute: www.oss-institute.org
OpenSSL Core team: www.openssl.org


jorton at redhat

Oct 28, 2009, 7:13 AM

Post #7 of 16 (315 views)
Permalink
Re: svn commit: r829619 - in /httpd/httpd/trunk: ./ modules/ssl/ [In reply to]

On Mon, Oct 26, 2009 at 12:44:17AM +0100, Ruediger Pluem wrote:
> On 10/25/2009 06:21 PM, jorton[at]apache.org wrote:
> > Author: jorton
> > Date: Sun Oct 25 17:21:10 2009
> > New Revision: 829619
> >
> > URL: http://svn.apache.org/viewvc?rev=829619&view=rev
> > Log:
> > Add support for OCSP "stapling":
...
> Will there be documentation patches for the new directives?

Yes, I will try to get that done, I might not have time until after
ApacheCon though.

Thanks greatly for the review!

> > + timeout += time(NULL);
>
> Shouldn't we use apr_time_now here?

Yup, fixed in r830551.

> > +
> > + i2d_OCSP_RESPONSE(rsp, &p);
>
> Is this correct? p is already char *. So &p would be char **.
> If p gets changed by i2d_OCSP_RESPONSE our flag set above would get lost ???

This is correct. The preceding lines:

p = resp_der;

if (ok == TRUE) {
*p++ = 1;
timeout = mctx->stapling_cache_timeout;
}
else {
*p++ = 0;
timeout = mctx->stapling_errcache_timeout;
}


set the flag value in the first byte of the data block. The i2d_*
macros all take a char ** pointer, and move the pointer to the next byte
after the serialized data. (see e.g. the man page for i2d_X509)

> > + p++;
> > + resp_derlen--;
> > + rsp = d2i_OCSP_RESPONSE(NULL, &p, resp_derlen);
>
> Why &p and not p?

As above, the d2i_ macros also take a char ** pointer and move it to the
first byte after the encoded OCSP_RESPONSE.

...
> I guess we are missing some indention here.

Sorry about that - Guenter has fixed it all, thanks Guenter!

> > +done:
> > + if (id)
> > + OCSP_CERTID_free(id);
> > + if (req)
> > + OCSP_REQUEST_free(req);
> > + return rv;
> > +err:
> > + rv = FALSE;
> > + goto done;
>
> Looks a little bit like spaghetti code :-).

It's a bit annoying; it could be done using pool cleanups but that adds
significant complexity, or by in-lining the _free calls everywhere,
which is a bit error-pront. Not really sure either alternative is
better. C sucks ;)

> > + * Check for cached responses in session cache. If valid send back to
> > + * client. If absent or no longer valid query responder and update
> > + * cache. */
> > +static int stapling_cb(SSL *ssl, void *arg)
> > +{
> > + conn_rec *conn = (conn_rec *)SSL_get_app_data(ssl);
> > + server_rec *s = conn->base_server;
>
> Shouldn't we use mySrvFromConn(conn) here instead of conn->base_server?

Yup, fixed in r830546.

Thanks again!

Regards, Joe


jorton at redhat

Oct 28, 2009, 7:22 AM

Post #8 of 16 (314 views)
Permalink
Re: svn commit: r829619 - in /httpd/httpd/trunk: ./ modules/ssl/ [In reply to]

On Tue, Oct 27, 2009 at 03:14:55AM +0100, Guenter Knauf wrote:
> Hi Joe, Steve,
> I have some probs with getting this compiled;
> first its inclear for me from where HAVE_OCSP should get defined in
> ssl_toolkit.compat.h - for me it seems its not defined in line 42, thus
> #include <openssl/ocsp.h>
> in line 44 is not included, and causes compile errors on NetWare since
> later on in line 150 we have:
> #if (OPENSSL_VERSION_NUMBER >= 0x00908080)
> #ifndef OPENSSL_NO_TLSEXT
> #define HAVE_OCSP_STAPLING
> #endif
> #endif
> so HAVE_OCSP_STAPLING gets defined when !OPENSSL_NO_TLSEXT although
> ocsp.h was not included.

Hiya, I'm not sure I follow this. HAVE_OCSP should be defined by the
build system iff openssl/ocsp.h is present - the Netware scripts may
need to be updated for this. I've updated the #if's to check for
HAVE_OCSP in r830554; does this work for you?

(In case you didn't see my other message, thanks a lot for fixing the
indenting!)

Regards, Joe


fuankg at apache

Oct 28, 2009, 8:05 AM

Post #9 of 16 (314 views)
Permalink
Re: svn commit: r829619 - in /httpd/httpd/trunk: ./ modules/ssl/ [In reply to]

Hi Joe,
Joe Orton schrieb:
> Hiya, I'm not sure I follow this. HAVE_OCSP should be defined by the
> build system iff openssl/ocsp.h is present - the Netware scripts may
> need to be updated for this. I've updated the #if's to check for
> HAVE_OCSP in r830554; does this work for you?
yes, works noe for the case where HAVE_OCSP is not defined; that was
what I also was thinking of.

but I still cant find anything in the OpenSSL sources where HAVE_OCSP
should get defined? I've searched through 0.9.8 / 1.0.0 witgh my NetWare
builds as well as through 1.0.0 of my Linux build, cant find ...
In which file do you have this macro defined with your build?
what am I missing?

Gün.


rpluem at apache

Oct 28, 2009, 8:09 AM

Post #10 of 16 (314 views)
Permalink
Re: svn commit: r829619 - in /httpd/httpd/trunk: ./ modules/ssl/ [In reply to]

On 10/28/2009 04:05 PM, Guenter Knauf wrote:
> Hi Joe,
> Joe Orton schrieb:
>> Hiya, I'm not sure I follow this. HAVE_OCSP should be defined by the
>> build system iff openssl/ocsp.h is present - the Netware scripts may
>> need to be updated for this. I've updated the #if's to check for
>> HAVE_OCSP in r830554; does this work for you?
> yes, works noe for the case where HAVE_OCSP is not defined; that was
> what I also was thinking of.
>
> but I still cant find anything in the OpenSSL sources where HAVE_OCSP
> should get defined? I've searched through 0.9.8 / 1.0.0 witgh my NetWare
> builds as well as through 1.0.0 of my Linux build, cant find ...
> In which file do you have this macro defined with your build?
> what am I missing?

Have a look at modules/ssl/config.m4:

AC_DEFUN([CHECK_OCSP], [
AC_CHECK_HEADERS(openssl/ocsp.h,·
[AC_DEFINE([HAVE_OCSP], 1, [Define if OCSP is supported by OpenSSL])]
)
])


Regards

Rüdiger


fuankg at apache

Oct 28, 2009, 8:11 AM

Post #11 of 16 (314 views)
Permalink
Re: svn commit: r829619 - in /httpd/httpd/trunk: ./ modules/ssl/ [In reply to]

Joe,
Joe Orton schrieb:
> Hiya, I'm not sure I follow this. HAVE_OCSP should be defined by the
> build system iff openssl/ocsp.h is present - the Netware scripts may
> need to be updated for this. I've updated the #if's to check for
or maybe I misunderstood you here: do you mean I should modify the
NetWare makefile for mod_ssl to check for presence of openssl/ocsp.h,
and add HAVE_OCSP to CFLAGS depending on the result?

Well, I guess its possible to do that - but isnt it possible to depend
on a OpenSSL version number here?

Gün.


shenson at oss-institute

Oct 28, 2009, 8:26 AM

Post #12 of 16 (314 views)
Permalink
Re: svn commit: r829619 - in /httpd/httpd/trunk: ./ modules/ssl/ [In reply to]

Guenter Knauf wrote:
>
> Well, I guess its possible to do that - but isnt it possible to depend
> on a OpenSSL version number here?
>

How far do we have to go back here? OCSP support has been in OpenSSL since
version 0.9.7 release 19 Feb 2003.

Steve.
--
Dr Stephen N. Henson. Senior Technical/Cryptography Advisor,
Open Source Software Institute: www.oss-institute.org
OpenSSL Core team: www.openssl.org


fuankg at apache

Oct 28, 2009, 8:32 AM

Post #13 of 16 (315 views)
Permalink
Re: svn commit: r829619 - in /httpd/httpd/trunk: ./ modules/ssl/ [In reply to]

Steve,
Dr Stephen Henson schrieb:
> Guenter Knauf wrote:
>> Well, I guess its possible to do that - but isnt it possible to depend
>> on a OpenSSL version number here?
>>
>
> How far do we have to go back here? OCSP support has been in OpenSSL since
> version 0.9.7 release 19 Feb 2003.
yep, found that just too - so a check for version 0.9.7 would do unless
this header is only conditionally installed (which I doubt) ...

Gün.


fuankg at apache

Oct 28, 2009, 8:40 AM

Post #14 of 16 (314 views)
Permalink
Re: svn commit: r829619 - in /httpd/httpd/trunk: ./ modules/ssl/ [In reply to]

Dr Stephen Henson schrieb:
> Guenter Knauf wrote:
>> Well, I guess its possible to do that - but isnt it possible to depend
>> on a OpenSSL version number here?
>>
>
> How far do we have to go back here? OCSP support has been in OpenSSL since
> version 0.9.7 release 19 Feb 2003.
we have:

+#if OPENSSL_VERSION_NUMBER >= 0x00908080 && defined(HAVE_OCSP) \
+ && !defined(OPENSSL_NO_TLSEXT)
#define HAVE_OCSP_STAPLING
#endif

so we only support HAVE_OCSP_STAPLING with OpenSSL >= 0x00908080, and it
seems that we dont need to include openssl/ocsp.h if we dont set
HAVE_OCSP_STAPLING, so lets just move the above check up, and modify to:

#if (OPENSSL_VERSION_NUMBER >= 0x00908080) \
&& !defined(OPENSSL_NO_TLSEXT)
#define HAVE_OCSP_STAPLING
#include <openssl/ocsp.h>
#endif

and no further need for a HAVE_OCSP define on any platform ...

comments?

Gün.


rpluem at apache

Oct 28, 2009, 9:38 AM

Post #15 of 16 (315 views)
Permalink
Re: svn commit: r829619 - in /httpd/httpd/trunk: ./ modules/ssl/ [In reply to]

On 10/28/2009 04:40 PM, Guenter Knauf wrote:
> Dr Stephen Henson schrieb:
>> Guenter Knauf wrote:
>>> Well, I guess its possible to do that - but isnt it possible to depend
>>> on a OpenSSL version number here?
>>>
>> How far do we have to go back here? OCSP support has been in OpenSSL since
>> version 0.9.7 release 19 Feb 2003.
> we have:
>
> +#if OPENSSL_VERSION_NUMBER >= 0x00908080 && defined(HAVE_OCSP) \
> + && !defined(OPENSSL_NO_TLSEXT)
> #define HAVE_OCSP_STAPLING
> #endif
>
> so we only support HAVE_OCSP_STAPLING with OpenSSL >= 0x00908080, and it
> seems that we dont need to include openssl/ocsp.h if we dont set
> HAVE_OCSP_STAPLING, so lets just move the above check up, and modify to:
>
> #if (OPENSSL_VERSION_NUMBER >= 0x00908080) \
> && !defined(OPENSSL_NO_TLSEXT)
> #define HAVE_OCSP_STAPLING
> #include <openssl/ocsp.h>
> #endif
>
> and no further need for a HAVE_OCSP define on any platform ...
>
> comments?

We do not need it only for OCSP stapling but also for "normal" OCSP support.
See ssl_util_ocsp.c
So HAVE_OCSP IMHO still makes sense. Or we need to rely everywhere entirely
on the OPENSSL_VERSION_NUMBER macro for deciding whether we have OCSP / OCSP stapling support.

Regards

Rüdiger


fuankg at apache

Oct 28, 2009, 2:27 PM

Post #16 of 16 (314 views)
Permalink
Re: svn commit: r829619 - in /httpd/httpd/trunk: ./ modules/ssl/ [In reply to]

Ruediger Pluem schrieb:
> We do not need it only for OCSP stapling but also for "normal" OCSP support.
> See ssl_util_ocsp.c
> So HAVE_OCSP IMHO still makes sense. Or we need to rely everywhere entirely
> on the OPENSSL_VERSION_NUMBER macro for deciding whether we have OCSP / OCSP stapling support.
thanks! Missed that ...
have now changed this:
http://svn.apache.org/viewvc?rev=830765&view=rev
this should work (and works with my tests) since all files which use
HAVE_OCSP either include ssl_toolkit_compat.h directly, or via
ssl_private.h ...

provided this works correctly, is it enough to just delete the check
part in the m4 file?

thanks, Gün.

Apache dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.