ssl_engine_log.c revision 93e04e27f5508c78897599cc15abd27ffbbd5424
/* _ _
** _ __ ___ ___ __| | ___ ___| | mod_ssl
** | '_ ` _ \ / _ \ / _` | / __/ __| | Apache Interface to OpenSSL
** | | | | | | (_) | (_| | \__ \__ \ | www.modssl.org
** |_| |_| |_|\___/ \__,_|___|___/___/_| ftp.modssl.org
** |_____|
** Logging Facility
*/
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*/
/* ``The difference between a computer
industry job and open-source software
hacking is about 30 hours a week.''
-- Ralf S. Engelschall */
#include "mod_ssl.h"
/* _________________________________________________________________
**
** Logfile Support
** _________________________________________________________________
*/
/*
* Open the SSL logfile
*/
{
const char *szLogFile;
/*
* Short-circuit for inherited logfiles in order to save
* filedescriptors in mass-vhost situation. Be careful, this works
* fine because the close happens implicitly by the pool facility.
*/
if ((s != s_main) &&
{
}
return;
"Cannot open reliable pipe to SSL logfile filter %s", szLogFile);
ssl_die();
}
}
else {
if (!szLogFile) {
ssl_die();
}
!= APR_SUCCESS) {
"Cannot open SSL logfile %s", szLogFile);
ssl_die();
}
}
}
return;
}
static struct {
int nLevel;
char *szLevel;
} ssl_log_level2string[] = {
{ SSL_LOG_ERROR, "error" },
{ SSL_LOG_WARN, "warn" },
{ SSL_LOG_INFO, "info" },
{ SSL_LOG_TRACE, "trace" },
{ SSL_LOG_DEBUG, "debug" },
{ 0, NULL }
};
static struct {
char *cpPattern;
char *cpAnnotation;
} ssl_log_annotate[] = {
{ "*envelope*bad*decrypt*", "wrong pass phrase!?" },
{ "*CLIENT_HELLO*unknown*protocol*", "speaking not SSL to HTTPS port!?" },
{ "*CLIENT_HELLO*http*request*", "speaking HTTP to HTTPS port!?" },
{ "*SSL3_READ_BYTES:sslv3*alert*bad*certificate*", "Subject CN in certificate not server name or identical to CA!?" },
{ "*self signed certificate in certificate chain*", "Client certificate signed by CA not known to server?" },
{ "*peer did not return a certificate*", "No CAs known to server for verification?" },
{ "*no shared cipher*", "Too restrictive SSLCipherSuite or using DSA server certificate?" },
{ "*no start line*", "Bad file contents or format - or even just a forgotten SSLCertificateKeyFile?" },
{ "*bad password read*", "You entered an incorrect pass phrase!?" },
{ "*bad mac decode*", "Browser still remembered details of a re-created server certificate?" },
};
static char *ssl_log_annotation(char *error)
{
char *errstr;
int i;
break;
}
}
return errstr;
}
{
char tstr[80];
char lstr[256];
char vstr[1024];
char str[1024];
char *nstr;
int add;
int i;
char *astr;
int safe_errno;
unsigned long e;
char *cpE;
char *cpA;
/* initialization */
safe_errno = errno;
sc = mySrvConfig(s);
/* strip out additional flags */
/* reduce flags when not reasonable in context */
add &= ~SSL_ADD_ERRNO;
add &= ~SSL_ADD_SSLERR;
/* we log only levels below, except for errors */
&& !(level & SSL_LOG_ERROR))
return;
&& !(level & SSL_LOG_ERROR))
return;
/* determine the time entry string */
if (add & SSL_NO_TIMESTAMP)
else {
apr_explode_localtime(&t, apr_time_now());
(unsigned int)getpid());
}
/* determine whether newline should be written */
if (add & SSL_NO_NEWLINE)
nstr = "";
else {
nstr = APR_EOL_STR;
}
/* determine level name */
if (!(add & SSL_NO_LEVELID)) {
for (i = 0; ssl_log_level2string[i].nLevel != 0; i++) {
break;
}
}
lstr[i] = ' ';
}
}
/* create custom message */
/* write out SSLog message */
else if (add & SSL_ADD_ERRNO)
astr = " (System error follows)";
else if (add & SSL_ADD_SSLERR)
else
astr = "";
}
if (level & SSL_LOG_ERROR)
/* write out additional attachment messages */
if (add & SSL_ADD_ERRNO) {
}
if (level & SSL_LOG_ERROR)
"System: %s (errno: %d)",
}
if (add & SSL_ADD_SSLERR) {
while ((e = ERR_get_error())) {
nstr);
}
if (level & SSL_LOG_ERROR)
}
}
/* make sure the next log starts from a clean base */
/* ERR_clear_error(); */
/* cleanup and return */
errno = safe_errno;
return;
}
void ssl_die(void)
{
/*
* This is used for fatal errors and here
* it is common module practice to really
* exit from the complete program.
*/
exit(1);
}