Print debug messages only in debug mode. Closes #779
authorAlan T. DeKok <aland@freeradius.org>
Wed, 3 Sep 2014 14:52:54 +0000 (10:52 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 3 Sep 2014 14:52:54 +0000 (10:52 -0400)
src/modules/rlm_eap/types/rlm_eap_tls/rlm_eap_tls.c

index 04640e9..f1572a5 100644 (file)
@@ -354,7 +354,15 @@ 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);
+       /*
+        *      Only print debugging information if we're in debugging
+        *      mode.
+        */
+       if (debug_flag) {
+               bio_out = BIO_new_fp(stdout, BIO_NOCLOSE);
+       } else {
+               bio_out = NULL;
+       }
 
        BIO_set_conn_port(cbio, port);
 #if OPENSSL_VERSION_NUMBER < 0x1000003f
@@ -436,17 +444,22 @@ 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) {
@@ -460,9 +473,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;
        }