static void _generate_request (gnutls_datum_t * rdata, gnutls_x509_crt_t cert, gnutls_x509_crt_t issuer) { gnutls_ocsp_req_t req; int ret; unsigned char noncebuf[23]; gnutls_datum_t nonce = { noncebuf, sizeof (noncebuf) }; ret = gnutls_ocsp_req_init (&req); if (ret < 0) exit (1); ret = gnutls_ocsp_req_add_cert (req, GNUTLS_DIG_SHA1, issuer, cert); if (ret < 0) exit (1); ret = gnutls_rnd (GNUTLS_RND_RANDOM, nonce.data, nonce.size); if (ret < 0) exit (1); ret = gnutls_ocsp_req_set_nonce (req, 0, &nonce); if (ret < 0) exit (1); ret = gnutls_ocsp_req_export (req, rdata); if (ret != 0) exit (1); gnutls_ocsp_req_deinit (req); return; }
static void request_info (void) { gnutls_ocsp_req_t req; int ret; gnutls_datum_t dat; size_t size; ret = gnutls_ocsp_req_init (&req); if (ret < 0) error (EXIT_FAILURE, 0, "ocsp_req_init: %s", gnutls_strerror (ret)); if (HAVE_OPT(LOAD_REQUEST)) dat.data = (void*)read_binary_file (OPT_ARG(LOAD_REQUEST), &size); else dat.data = (void*)fread_file (infile, &size); if (dat.data == NULL) error (EXIT_FAILURE, errno, "reading request"); dat.size = size; ret = gnutls_ocsp_req_import (req, &dat); free (dat.data); if (ret < 0) error (EXIT_FAILURE, 0, "importing request: %s", gnutls_strerror (ret)); ret = gnutls_ocsp_req_print (req, GNUTLS_OCSP_PRINT_FULL, &dat); if (ret != 0) error (EXIT_FAILURE, 0, "ocsp_req_print: %s", gnutls_strerror (ret)); printf ("%.*s", dat.size, dat.data); gnutls_free (dat.data); gnutls_ocsp_req_deinit (req); }
static void request_info(void) { gnutls_ocsp_req_t req; int ret; gnutls_datum_t dat; size_t size; ret = gnutls_ocsp_req_init(&req); if (ret < 0) { fprintf(stderr, "ocsp_req_init: %s\n", gnutls_strerror(ret)); exit(1); } if (HAVE_OPT(LOAD_REQUEST)) dat.data = (void *) read_binary_file(OPT_ARG(LOAD_REQUEST), &size); else dat.data = (void *) fread_file(infile, &size); if (dat.data == NULL) { fprintf(stderr, "error reading request\n"); exit(1); } dat.size = size; ret = gnutls_ocsp_req_import(req, &dat); free(dat.data); if (ret < 0) { fprintf(stderr, "error importing request: %s\n", gnutls_strerror(ret)); exit(1); } ret = gnutls_ocsp_req_print(req, GNUTLS_OCSP_PRINT_FULL, &dat); if (ret != 0) { fprintf(stderr, "ocsp_req_print: %s\n", gnutls_strerror(ret)); exit(1); } printf("%.*s", dat.size, dat.data); gnutls_free(dat.data); gnutls_ocsp_req_deinit(req); }