ssl_util.c revision a943533fd4d91d114af622731a405407990c4fb1
e1e8390280254f7f0580d701e583f670643d4f3fnilgun** _ __ ___ ___ __| | ___ ___| | mod_ssl
e1e8390280254f7f0580d701e583f670643d4f3fnilgun** | '_ ` _ \ / _ \ / _` | / __/ __| | Apache Interface to OpenSSL
e1e8390280254f7f0580d701e583f670643d4f3fnilgun** | | | | | | (_) | (_| | \__ \__ \ | www.modssl.org
e1e8390280254f7f0580d701e583f670643d4f3fnilgun** |_| |_| |_|\___/ \__,_|___|___/___/_| ftp.modssl.org
e1e8390280254f7f0580d701e583f670643d4f3fnilgun** Utility Functions
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen/* ====================================================================
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * The Apache Software License, Version 1.1
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * reserved.
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * Redistribution and use in source and binary forms, with or without
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen * modification, are permitted provided that the following conditions
3f08db06526d6901aa08c110b5bc7dde6bc39905nd * are met:
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * 1. Redistributions of source code must retain the above copyright
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * notice, this list of conditions and the following disclaimer.
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * 2. Redistributions in binary form must reproduce the above copyright
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * notice, this list of conditions and the following disclaimer in
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * the documentation and/or other materials provided with the
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * distribution.
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * 3. The end-user documentation included with the redistribution,
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung * if any, must include the following acknowledgment:
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * "This product includes software developed by the
f0fa55ff14fa0bf8fd72d989f6625de6dc3260c8igalic * Apache Software Foundation (http://www.apache.org/)."
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * Alternately, this acknowledgment may appear in the software itself,
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * if and wherever such third-party acknowledgments normally appear.
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * 4. The names "Apache" and "Apache Software Foundation" must
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * not be used to endorse or promote products derived from this
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * software without prior written permission. For written
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * permission, please contact apache@apache.org.
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * 5. Products derived from this software may not be called "Apache",
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * nor may "Apache" appear in their name, without prior written
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * permission of the Apache Software Foundation.
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
e0cfea1f5d38eeaa8fdf7c197c3c1eb31148e191nilgun * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
2704de98885368683621b01c8f8f4e4b01557611takashi * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * SUCH DAMAGE.
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * ====================================================================
e1e8390280254f7f0580d701e583f670643d4f3fnilgun /* ``Every day of my life
c38e2a97e43fc69b22f6b03c6d2f60e3bd705f89sf I am forced to add another
e1e8390280254f7f0580d701e583f670643d4f3fnilgun name to the list of people
e1e8390280254f7f0580d701e583f670643d4f3fnilgun who piss me off!''
e1e8390280254f7f0580d701e583f670643d4f3fnilgun -- Calvin */
e1e8390280254f7f0580d701e583f670643d4f3fnilgun/* _________________________________________________________________
e1e8390280254f7f0580d701e583f670643d4f3fnilgun** Utility Functions
e1e8390280254f7f0580d701e583f670643d4f3fnilgun** _________________________________________________________________
e0cfea1f5d38eeaa8fdf7c197c3c1eb31148e191nilgun if (s->port != 0)
e1e8390280254f7f0580d701e583f670643d4f3fnilgun id = apr_psprintf(p, "%s:%lu", host, (unsigned long)port);
e1e8390280254f7f0580d701e583f670643d4f3fnilgun for (; *s; ++s)
e1e8390280254f7f0580d701e583f670643d4f3fnilgun "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
e1e8390280254f7f0580d701e583f670643d4f3fnilgunvoid ssl_util_uuencode(char *szTo, const char *szFrom, BOOL bPad)
e1e8390280254f7f0580d701e583f670643d4f3fnilgun (const unsigned char *)szFrom,
e1e8390280254f7f0580d701e583f670643d4f3fnilgun unsigned char *szTo, const unsigned char *szFrom, int nLength, BOOL bPad)
e1e8390280254f7f0580d701e583f670643d4f3fnilgun const unsigned char *s;
e1e8390280254f7f0580d701e583f670643d4f3fnilgun *szTo++ = ssl_util_uuencode_six2pr[(s[0] << 4 | s[1] >> 4) & 0x3f];
e1e8390280254f7f0580d701e583f670643d4f3fnilgun if (--nLength == 0) {
e1e8390280254f7f0580d701e583f670643d4f3fnilgun *szTo++ = ssl_util_uuencode_six2pr[(s[1] << 2 | s[2] >> 6) & 0x3f];
e1e8390280254f7f0580d701e583f670643d4f3fnilgun if (--nLength == 0) {
e1e8390280254f7f0580d701e583f670643d4f3fnilgunapr_file_t *ssl_util_ppopen(server_rec *s, apr_pool_t *p, char *cmd)
e1e8390280254f7f0580d701e583f670643d4f3fnilgun if (apr_procattr_create(&procattr, p) != APR_SUCCESS)
e1e8390280254f7f0580d701e583f670643d4f3fnilgun if (apr_procattr_io_set(procattr, APR_FULL_BLOCK, APR_FULL_BLOCK,
e0cfea1f5d38eeaa8fdf7c197c3c1eb31148e191nilgun if (apr_procattr_cmdtype_set(procattr, APR_PROGRAM) != APR_SUCCESS)
e0cfea1f5d38eeaa8fdf7c197c3c1eb31148e191nilgun if ((proc = (apr_proc_t *)apr_pcalloc(p, sizeof(apr_proc_t))) == NULL)
2704de98885368683621b01c8f8f4e4b01557611takashi if (apr_proc_create(proc, cmd, NULL, NULL, procattr, p) != APR_SUCCESS)
e0cfea1f5d38eeaa8fdf7c197c3c1eb31148e191nilgunvoid ssl_util_ppclose(server_rec *s, apr_pool_t *p, apr_file_t *fp)
e0cfea1f5d38eeaa8fdf7c197c3c1eb31148e191nilgun * Run a filter program and read the first line of its stdout output
e0cfea1f5d38eeaa8fdf7c197c3c1eb31148e191nilgunchar *ssl_util_readfilter(server_rec *s, apr_pool_t *p, char *cmd)
0d0ba3a410038e179b695446bb149cce6264e0abnd for (k = 0; apr_file_read(fp, &c, &nbytes) == APR_SUCCESS
0d0ba3a410038e179b695446bb149cce6264e0abndBOOL ssl_util_path_check(ssl_pathcheck_t pcm, char *path, apr_pool_t *p)
e1e8390280254f7f0580d701e583f670643d4f3fnilgun if (pcm & SSL_PCM_ISDIR && finfo.filetype != APR_DIR)
return FALSE;
return FALSE;
return TRUE;
ssl_algo_t t;
t = SSL_ALGO_UNKNOWN;
case EVP_PKEY_RSA:
t = SSL_ALGO_RSA;
case EVP_PKEY_DSA:
t = SSL_ALGO_DSA;
char *cp;
case SSL_ALGO_RSA:
case SSL_ALGO_DSA:
return cp;
char *ssl_util_ptxtsub(
char *cpResult;
int nResult;
int nLine;
int nSubst;
int nMatch;
char *cpI;
char *cpO;
char *cp;
return NULL;
return cpResult;
return mc;
conn_rec *c;
if (c != NULL)
return mc;