From: Alan T. DeKok Date: Wed, 3 Sep 2014 14:56:15 +0000 (-0400) Subject: Print debug messages only in debug mode. Closes #779 X-Git-Tag: release_3_0_5~639 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee3ea4a82472da3625c68bd087fb2df9b6fbfdd1;p=thirdparty%2Ffreeradius-server.git Print debug messages only in debug mode. Closes #779 --- diff --git a/src/main/tls.c b/src/main/tls.c index 3f4b5f51bc4..bf03e36f6e6 100644 --- a/src/main/tls.c +++ b/src/main/tls.c @@ -1364,7 +1364,14 @@ static int ocsp_check(X509_STORE *store, X509 *issuer_cert, X509 *client_cert, /* Setup BIO socket to OCSP responder */ cbio = BIO_new_connect(host); - bio_out = BIO_new_fp(stdout, BIO_NOCLOSE); + bio_out = NULL; + if (debug_flag) { + if (default_log.dst == L_DST_STDOUT) { + bio_out = BIO_new_fp(stdout, BIO_NOCLOSE); + } else if (default_log.dst == L_DST_STDERR) { + bio_out = BIO_new_fp(stderr, BIO_NOCLOSE); + } + } BIO_set_conn_port(cbio, port); #if OPENSSL_VERSION_NUMBER < 0x1000003f @@ -1447,17 +1454,23 @@ static int ocsp_check(X509_STORE *store, X509 *issuer_cert, X509 *client_cert, } if (!OCSP_check_validity(thisupd, nextupd, nsec, maxage)) { - BIO_puts(bio_out, "WARNING: Status times invalid.\n"); - ERR_print_errors(bio_out); + if (bio_out) { + BIO_puts(bio_out, "WARNING: Status times invalid.\n"); + ERR_print_errors(bio_out); + } goto ocsp_end; } - BIO_puts(bio_out, "\tThis Update: "); - ASN1_GENERALIZEDTIME_print(bio_out, thisupd); - BIO_puts(bio_out, "\n"); - if (nextupd) { - BIO_puts(bio_out, "\tNext Update: "); - ASN1_GENERALIZEDTIME_print(bio_out, nextupd); + + + if (bio_out) { + BIO_puts(bio_out, "\tThis Update: "); + ASN1_GENERALIZEDTIME_print(bio_out, thisupd); BIO_puts(bio_out, "\n"); + if (nextupd) { + BIO_puts(bio_out, "\tNext Update: "); + ASN1_GENERALIZEDTIME_print(bio_out, nextupd); + BIO_puts(bio_out, "\n"); + } } switch (status) { @@ -1471,9 +1484,12 @@ static int ocsp_check(X509_STORE *store, X509 *issuer_cert, X509 *client_cert, DEBUG2("[ocsp] --> Cert status: %s",OCSP_cert_status_str(status)); if (reason != -1) DEBUG2("[ocsp] --> Reason: %s", OCSP_crl_reason_str(reason)); - BIO_puts(bio_out, "\tRevocation Time: "); - ASN1_GENERALIZEDTIME_print(bio_out, rev); - BIO_puts(bio_out, "\n"); + + if (bio_out) { + BIO_puts(bio_out, "\tRevocation Time: "); + ASN1_GENERALIZEDTIME_print(bio_out, rev); + BIO_puts(bio_out, "\n"); + } break; }