MCPcopy Create free account
hub / github.com/apache/httpd / stapling_cb

Function stapling_cb

modules/ssl/ssl_util_stapling.c:804–927  ·  view source on GitHub ↗

Certificate Status callback. This is called when a client includes a * certificate status request extension. * * Check for cached responses in session cache. If valid send back to * client. If absent or no longer valid, query responder and update * cache. */

Source from the content-addressed store, hash-verified

802 * cache.
803 */
804static int stapling_cb(SSL *ssl, void *arg)
805{
806 conn_rec *conn = (conn_rec *)SSL_get_app_data(ssl);
807 server_rec *s = mySrvFromConn(conn);
808 SSLSrvConfigRec *sc = mySrvConfig(s);
809 modssl_ctx_t *mctx = myConnCtxConfig(conn, sc);
810 UCHAR idx[SHA_DIGEST_LENGTH];
811 ocsp_resp resp;
812 certinfo *cinf = NULL;
813 OCSP_RESPONSE *rsp = NULL;
814 int rv;
815 BOOL ok = TRUE;
816 X509 *x;
817 int rspderlen, provided = 0;
818
819 ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(01951)
820 "stapling_cb: OCSP Stapling callback called");
821
822 x = SSL_get_certificate(ssl);
823 if (x == NULL) {
824 return SSL_TLSEXT_ERR_NOACK;
825 }
826
827 if (X509_digest(x, EVP_sha1(), idx, NULL) != 1) {
828 return SSL_TLSEXT_ERR_NOACK;
829 }
830
831 if (ap_ssl_ocsp_get_resp(s, conn, (const char*)idx, sizeof(idx),
832 copy_ocsp_resp, &resp) == APR_SUCCESS) {
833 provided = 1;
834 }
835 else if (ssl_run_get_stapling_status(&resp.data, &rspderlen, conn, s, x) == APR_SUCCESS) {
836 resp.len = (apr_size_t)rspderlen;
837 provided = 1;
838 }
839
840 if (provided) {
841 /* a hook handles stapling for this certificate and determines the response */
842 if (resp.data == NULL || resp.len == 0) {
843 return SSL_TLSEXT_ERR_NOACK;
844 }
845 SSL_set_tlsext_status_ocsp_resp(ssl, resp.data, (int)resp.len);
846 return SSL_TLSEXT_ERR_OK;
847 }
848
849 if (sc->server->stapling_enabled != TRUE) {
850 ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(01950)
851 "stapling_cb: OCSP Stapling disabled");
852 return SSL_TLSEXT_ERR_NOACK;
853 }
854
855 if ((cinf = stapling_get_certinfo(s, idx, sizeof(idx), mctx, ssl)) == NULL) {
856 return SSL_TLSEXT_ERR_NOACK;
857 }
858
859 ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(01952)
860 "stapling_cb: retrieved cached certificate data");
861

Callers

nothing calls this directly

Calls 8

ap_ssl_ocsp_get_respFunction · 0.85
stapling_get_certinfoFunction · 0.85
stapling_renew_responseFunction · 0.85
stapling_set_responseFunction · 0.85
ap_log_errorFunction · 0.50

Tested by

no test coverage detected