httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From do...@apache.org
Subject cvs commit: httpd-2.0/modules/ssl ssl_engine_config.c
Date Tue, 12 Mar 2002 19:02:22 GMT
dougm       02/03/12 11:02:22

  Modified:    modules/ssl ssl_engine_config.c
  Log:
  fold some duplication of server certs/keys directive checking into
  ssl_cmd_check_aidx_max function.
  
  Revision  Changes    Path
  1.30      +41 -25    httpd-2.0/modules/ssl/ssl_engine_config.c
  
  Index: ssl_engine_config.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/ssl/ssl_engine_config.c,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- ssl_engine_config.c	12 Mar 2002 18:34:19 -0000	1.29
  +++ ssl_engine_config.c	12 Mar 2002 19:02:22 -0000	1.30
  @@ -559,52 +559,68 @@
   
   }
   
  -const char *ssl_cmd_SSLCertificateFile(cmd_parms *cmd, void *ctx,
  -                                       const char *arg)
  +#define SSL_AIDX_CERTS 1
  +#define SSL_AIDX_KEYS  2
  +
  +static const char *ssl_cmd_check_aidx_max(cmd_parms *parms,
  +                                          const char *arg,
  +                                          int idx)
   {
  -    SSLSrvConfigRec *sc = mySrvConfig(cmd->server);
  -    const char *err;
  +    SSLSrvConfigRec *sc = mySrvConfig(parms->server);
  +    const char *err, *desc, **files;
       int i;
   
  -    if ((err = ssl_cmd_check_file(cmd, &arg))) {
  +    if ((err = ssl_cmd_check_file(parms, &arg))) {
           return err;
       }
   
  +    switch (idx) {
  +      case SSL_AIDX_CERTS:
  +        desc = "certificates";
  +        files = sc->szPublicCertFile;
  +        break;
  +      case SSL_AIDX_KEYS:
  +        desc = "private keys";
  +        files = sc->szPrivateKeyFile;
  +        break;
  +    }
  +
       for (i = 0; i < SSL_AIDX_MAX; i++) {
  -        if (!sc->szPublicCertFile[i]) {
  -            sc->szPublicCertFile[i] = arg;
  +        if (!files[i]) {
  +            files[i] = arg;
               return NULL;
           }
       }
   
  -    return apr_psprintf(cmd->pool,
  -                        "SSLCertificateFile: only up to %d "
  -                        "different certificates per virtual host allowed", 
  -                        SSL_AIDX_MAX);
  +    return apr_psprintf(parms->pool,
  +                        "%s: only up to %d "
  +                        "different %s per virtual host allowed", 
  +                         parms->cmd->name, SSL_AIDX_MAX, desc);
   }
   
  -const char *ssl_cmd_SSLCertificateKeyFile(cmd_parms *cmd, void *ctx,
  -                                          const char *arg)
  +const char *ssl_cmd_SSLCertificateFile(cmd_parms *cmd, void *ctx,
  +                                       const char *arg)
   {
  -    SSLSrvConfigRec *sc = mySrvConfig(cmd->server);
  +
       const char *err;
  -    int i;
   
  -    if ((err = ssl_cmd_check_file(cmd, &arg))) {
  +    if ((err = ssl_cmd_check_aidx_max(cmd, arg, SSL_AIDX_CERTS))) {
           return err;
       }
   
  -    for (i = 0; i < SSL_AIDX_MAX; i++) {
  -        if (!sc->szPrivateKeyFile[i]) {
  -            sc->szPrivateKeyFile[i] = arg;
  -            return NULL;
  -        }
  +    return NULL;
  +}
  +
  +const char *ssl_cmd_SSLCertificateKeyFile(cmd_parms *cmd, void *ctx,
  +                                          const char *arg)
  +{
  +    const char *err;
  +
  +    if ((err = ssl_cmd_check_aidx_max(cmd, arg, SSL_AIDX_KEYS))) {
  +        return err;
       }
   
  -    return apr_psprintf(cmd->pool,
  -                        "SSLCertificateKeyFile: only up to %d "
  -                        "different private keys per virtual host allowed", 
  -                        SSL_AIDX_MAX);
  +    return NULL;
   }
   
   const char *ssl_cmd_SSLCertificateChainFile(cmd_parms *cmd, void *ctx,
  
  
  

Mime
View raw message