summaryrefslogtreecommitdiff
path: root/lib/ext
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2017-10-13 09:31:58 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2018-02-19 15:29:36 +0100
commitf4a069f23389c1c7bfbad823e8b599b5cfc3fb76 (patch)
tree42dacaf4b198d6d494df4ca73985743b16579652 /lib/ext
parent375d9ed8ca2c83ba8d50214884fe1aa753c0fd88 (diff)
downloadgnutls-f4a069f23389c1c7bfbad823e8b599b5cfc3fb76.tar.gz
gnutls_ocsp_status_request_get2: added function
The function extends gnutls_ocsp_status_request_get() to retrieve more than a single responses. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Diffstat (limited to 'lib/ext')
-rw-r--r--lib/ext/status_request.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/lib/ext/status_request.c b/lib/ext/status_request.c
index 452a13ed06..8b16ac0478 100644
--- a/lib/ext/status_request.c
+++ b/lib/ext/status_request.c
@@ -315,19 +315,49 @@ int
gnutls_ocsp_status_request_get(gnutls_session_t session,
gnutls_datum_t * response)
{
+ return gnutls_ocsp_status_request_get2(session, 0, response);
+}
+
+/**
+ * gnutls_ocsp_status_request_get2:
+ * @session: is a #gnutls_session_t type.
+ * @idx: the index of peer's certificate
+ * @response: a #gnutls_datum_t with DER encoded OCSP response
+ *
+ * This function returns the OCSP status response received
+ * from the TLS server for the certificate index provided.
+ * The index corresponds to certificates as returned by
+ * gnutls_certificate_get_peers. When index is zero this
+ * function operates identically to gnutls_ocsp_status_request_get().
+ *
+ * The returned @response should be treated as
+ * constant. If no OCSP response is available for the
+ * given index then %GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE
+ * is returned.
+ *
+ * Returns: On success, %GNUTLS_E_SUCCESS (0) is returned,
+ * otherwise a negative error code is returned.
+ *
+ * Since: 3.6.xx
+ **/
+int
+gnutls_ocsp_status_request_get2(gnutls_session_t session,
+ unsigned idx,
+ gnutls_datum_t * response)
+{
cert_auth_info_t info = _gnutls_get_auth_info(session, GNUTLS_CRD_CERTIFICATE);
if (session->security_parameters.entity == GNUTLS_SERVER)
return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST);
if (info == NULL || info->raw_ocsp_list == NULL ||
- info->nocsp == 0 || info->raw_ocsp_list[0].size == 0)
+ idx >= info->nocsp || info->raw_ocsp_list[idx].size == 0)
return
gnutls_assert_val
(GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE);
- response->data = info->raw_ocsp_list[0].data;
- response->size = info->raw_ocsp_list[0].size;
+ response->data = info->raw_ocsp_list[idx].data;
+ response->size = info->raw_ocsp_list[idx].size;
return 0;
}