From 2d2cbe6ee646a7a002f613fe04f69afd14096771 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Tue, 12 Mar 2002 19:02:22 +0000 Subject: [PATCH] fold some duplication of server certs/keys directive checking into ssl_cmd_check_aidx_max function. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@93864 13f79535-47bb-0310-9956-ffa450edef68 --- modules/ssl/ssl_engine_config.c | 66 ++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/modules/ssl/ssl_engine_config.c b/modules/ssl/ssl_engine_config.c index 4cde7dd28d..4ff11a1eab 100644 --- a/modules/ssl/ssl_engine_config.c +++ b/modules/ssl/ssl_engine_config.c @@ -559,52 +559,68 @@ static const char *ssl_cmd_check_dir(cmd_parms *parms, } -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, -- 2.40.0