You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by do...@apache.org on 2002/03/29 05:50:37 UTC

cvs commit: httpd-2.0/modules/ssl mod_ssl.c mod_ssl.h

dougm       02/03/28 20:50:37

  Modified:    modules/ssl mod_ssl.c mod_ssl.h
  Log:
  add optional function (ssl_proxy_enable) to turn on ssl proxy
  
  choose SSL_CTX based on SSLConnRec.is_proxy
  
  Revision  Changes    Path
  1.57      +38 -5     httpd-2.0/modules/ssl/mod_ssl.c
  
  Index: mod_ssl.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/ssl/mod_ssl.c,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- mod_ssl.c	29 Mar 2002 03:05:49 -0000	1.56
  +++ mod_ssl.c	29 Mar 2002 04:50:37 -0000	1.57
  @@ -215,24 +215,53 @@
       return OK;
   }
   
  +static SSLConnRec *ssl_init_connection_ctx(conn_rec *c)
  +{
  +    SSLConnRec *sslconn = myConnConfig(c);
  +
  +    if (sslconn) {
  +        return sslconn;
  +    }
  +
  +    sslconn = apr_pcalloc(c->pool, sizeof(*sslconn));
  +
  +    myConnConfigSet(c, sslconn);
  +
  +    return sslconn;
  +}
  +
  +int ssl_proxy_enable(conn_rec *c)
  +{
  +    SSLConnRec *sslconn = ssl_init_connection_ctx(c);
  +
  +    sslconn->is_proxy = 1;
  +
  +    return 1;
  +}
  +
   static int ssl_hook_pre_connection(conn_rec *c, void *csd)
   {
       SSLSrvConfigRec *sc = mySrvConfig(c->base_server);
       SSL *ssl;
  -    SSLConnRec *sslconn;
  +    SSLConnRec *sslconn = myConnConfig(c);
  +    modssl_ctx_t *mctx;
   
       /*
        * Immediately stop processing if SSL is disabled for this connection
        */
  -    if (!(sc && sc->enabled)) {
  +    if (!(sc && (sc->enabled ||
  +                 (sslconn && sslconn->is_proxy))))
  +    {
           return DECLINED;
       }
   
       /*
        * Create SSL context
        */
  -    sslconn = apr_pcalloc(c->pool, sizeof(*sslconn));
  -    myConnConfigSet(c, sslconn);
  +    if (!sslconn) {
  +        sslconn = ssl_init_connection_ctx(c);
  +    }
  +
       sslconn->log_level = sc->log_level;
   
       /*
  @@ -250,12 +279,14 @@
        */
       ssl_rand_seed(c->base_server, c->pool, SSL_RSCTX_CONNECT, "");
   
  +    mctx = sslconn->is_proxy ? sc->proxy : sc->server;
  +
       /*
        * Create a new SSL connection with the configured server SSL context and
        * attach this to the socket. Additionally we register this attachment
        * so we can detach later.
        */
  -    if (!(ssl = SSL_new(sc->server->ssl_ctx))) {
  +    if (!(ssl = SSL_new(mctx->ssl_ctx))) {
           ssl_log(c->base_server, SSL_LOG_ERROR|SSL_ADD_SSLERR,
                   "Unable to create a new SSL connection from the SSL context");
   
  @@ -500,6 +531,8 @@
       ap_hook_post_read_request(ssl_hook_ReadReq,    NULL,NULL, APR_HOOK_MIDDLE);
   
       ssl_var_register();
  +
  +    APR_REGISTER_OPTIONAL_FN(ssl_proxy_enable);
   }
   
   module AP_MODULE_DECLARE_DATA ssl_module = {
  
  
  
  1.105     +6 -0      httpd-2.0/modules/ssl/mod_ssl.h
  
  Index: mod_ssl.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/ssl/mod_ssl.h,v
  retrieving revision 1.104
  retrieving revision 1.105
  diff -u -r1.104 -r1.105
  --- mod_ssl.h	29 Mar 2002 03:05:49 -0000	1.104
  +++ mod_ssl.h	29 Mar 2002 04:50:37 -0000	1.105
  @@ -430,6 +430,7 @@
       const char *verify_error;
       int verify_depth;
       int log_level; /* for avoiding expensive logging */
  +    int is_proxy;
   } SSLConnRec;
   
   #define SSLConnLogApplies(sslconn, level) (sslconn->log_level >= level)
  @@ -712,6 +713,11 @@
                           (apr_pool_t *, server_rec *,
                            conn_rec *, request_rec *,
                            char *));
  +
  +/* Proxy Support */
  +int ssl_proxy_enable(conn_rec *c);
  +
  +APR_DECLARE_OPTIONAL_FN(int, ssl_proxy_enable, (conn_rec *));
   
   /*  I/O  */
   void         ssl_io_filter_init(conn_rec *, SSL *);