]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
gnutls-cli: added option to save the OCSP response
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Thu, 13 Nov 2014 13:12:15 +0000 (14:12 +0100)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Thu, 13 Nov 2014 13:12:18 +0000 (14:12 +0100)
src/cli-args.def
src/cli.c
src/common.c

index 382c9421c30f41f1d02d743eeec297a582837b49..05a46396fbc30d480747165670e00c74acdb4325 100644 (file)
@@ -127,6 +127,13 @@ flag = {
     doc      = "";
 };
 
+flag = {
+    name      = save-ocsp;
+    arg-type  = string;
+    descrip   = "Save the peer's OCSP status response in the provided file";
+    doc      = "";
+};
+
 flag = {
     name      = dh-bits;
     arg-type  = number;
index ab4f83ef98663ab0dcf4848a3be87ce6080da4fd..c7f3bfeb52b146c8b4510b8616db94b17d97e8cc 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -1040,6 +1040,24 @@ int do_inline_command_processing(char *buffer_ptr, size_t curr_bytes,
        }
 }
 
+static void
+print_other_info(gnutls_session_t session)
+{
+       int ret;
+       gnutls_datum_t data;
+
+       if (HAVE_OPT(SAVE_OCSP)) {
+               FILE *fp = fopen(OPT_ARG(SAVE_OCSP), "w");
+
+               if (fp != NULL) {
+                       ret = gnutls_ocsp_status_request_get(session, &data);
+                       if (ret >= 0)
+                               fwrite(data.data, 1, data.size, fp);
+                       fclose(fp);
+               }
+       }
+}
+
 int main(int argc, char **argv)
 {
        int ret;
@@ -1094,6 +1112,8 @@ int main(int argc, char **argv)
                if (try_resume(&hd))
                        return 1;
 
+       print_other_info(hd.session);
+
       after_handshake:
 
        /* Warning!  Do not touch this text string, it is used by external
index 59fe728938c527248ba4a27b280f52ff742d6c7b..eaff478cdf857a3b5a6d3b040f7f22573386f2ec 100644 (file)
@@ -562,8 +562,9 @@ int print_info(gnutls_session_t session, int verbose, int print_cert)
                printf(" safe renegotiation,");
        if (gnutls_session_etm_status(session)!=0)
                printf(" EtM,");
-       if (gnutls_ocsp_status_request_is_checked(session, GNUTLS_OCSP_SR_IS_AVAIL)!=0)
-               printf(" OCSP status request,");
+       if (gnutls_ocsp_status_request_is_checked(session, GNUTLS_OCSP_SR_IS_AVAIL)!=0) {
+               printf(" OCSP status request%s,", gnutls_ocsp_status_request_is_checked(session,0)!=0?"":"[ignored]");
+       }
        printf("\n");
 
 #ifdef ENABLE_DTLS_SRTP