]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Print debug messages only in debug mode. Closes #779
authorAlan T. DeKok <aland@freeradius.org>
Wed, 3 Sep 2014 14:56:15 +0000 (10:56 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 3 Sep 2014 14:56:15 +0000 (10:56 -0400)
src/main/tls.c

index 3f4b5f51bc4f4940be1b24b067f82b9829f37093..bf03e36f6e67b1dd33751935e16177e1d3764054 100644 (file)
@@ -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;
        }