From: Nikos Mavrogiannopoulos Date: Thu, 13 Nov 2014 13:12:15 +0000 (+0100) Subject: gnutls-cli: added option to save the OCSP response X-Git-Tag: gnutls_3_4_0~633 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d75304f487cb4faf9443fb074ca6771f3bf65c10;p=thirdparty%2Fgnutls.git gnutls-cli: added option to save the OCSP response --- diff --git a/src/cli-args.def b/src/cli-args.def index 382c9421c3..05a46396fb 100644 --- a/src/cli-args.def +++ b/src/cli-args.def @@ -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; diff --git a/src/cli.c b/src/cli.c index ab4f83ef98..c7f3bfeb52 100644 --- 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 diff --git a/src/common.c b/src/common.c index 59fe728938..eaff478cdf 100644 --- a/src/common.c +++ b/src/common.c @@ -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