master
1#ifndef HEADER_CURL_SSLUSE_H
2#define HEADER_CURL_SSLUSE_H
3/***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
10 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
11 *
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at https://curl.se/docs/copyright.html.
15 *
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 * SPDX-License-Identifier: curl
24 *
25 ***************************************************************************/
26#include "curl_setup.h"
28#ifdef USE_OPENSSL
30#ifdef USE_WIN32_CRYPTO
31#include <wincrypt.h>
32/* If <wincrypt.h> is included directly, or indirectly via <schannel.h>,
33 * <winldap.h>, <iphlpapi.h>, or something else, <wincrypt.h> does this:
34 * #define X509_NAME ((LPCSTR)7)
35 *
36 * In AWS-LC/BoringSSL's <openssl/base.h> there is:
37 * typedef struct X509_name_st X509_NAME;
38 * etc.
39 *
40 * The redefined symbols break these OpenSSL headers when included after
41 * <wincrypt.h>.
42 * The workaround is to undefine those defines here (and only here).
43 *
44 * For unity builds it may need to be repeated elsewhere too, e.g. in ldap.c,
45 * to apply to other sources using OpenSSL includes. Each compilation unit
46 * needs undefine them between the first <wincrypt.h> include and the first
47 * OpenSSL include.
48 *
49 * OpenSSL does this in <openssl/ssl.h> and <openssl/x509v3.h>, but it
50 * also does the #undef by including <openssl/ossl_typ.h>. <3.1.0 only does
51 * it on the first include.
52 *
53 * LibreSSL automatically undefines these symbols before using them.
54 */
55#undef X509_NAME
56#undef X509_EXTENSIONS
57#undef PKCS7_ISSUER_AND_SERIAL
58#undef PKCS7_SIGNER_INFO
59#undef OCSP_REQUEST
60#undef OCSP_RESPONSE
61#endif /* USE_WIN32_CRYPTO */
63/*
64 * This header should only be needed to get included by vtls.c, openssl.c
65 * and ngtcp2.c
66 */
67#include <openssl/opensslv.h>
68#include <openssl/ossl_typ.h>
69#include <openssl/ssl.h>
71#include "urldata.h"
73#if OPENSSL_VERSION_NUMBER >= 0x30000000L
74#define HAVE_OPENSSL3 /* non-fork OpenSSL 3.x or later */
75#endif
77#if defined(OPENSSL_IS_AWSLC) || defined(OPENSSL_IS_BORINGSSL)
78#define HAVE_BORINGSSL_LIKE
79#endif
81/* OpenSSL 3.5.0+ has built-in 'SSLKEYLOGFILE' support if built with
82 'enable-sslkeylog' */
83#if OPENSSL_VERSION_NUMBER >= 0x30500000L && !defined(OPENSSL_NO_SSLKEYLOG)
84#define HAVE_KEYLOG_UPSTREAM
85#endif
87/*
88 * Whether SSL_CTX_set_keylog_callback is available.
89 * BoringSSL: supported since d28f59c27bac (committed 2015-11-19)
90 * LibreSSL: not supported. 3.5.0+ has a stub function that does nothing.
91 * OpenSSL: supported since 1.1.1 https://github.com/openssl/openssl/pull/2287
92 */
93#ifndef LIBRESSL_VERSION_NUMBER
94#define HAVE_KEYLOG_CALLBACK
95#endif
97/* Check for OpenSSL 1.1.1 which has early data support. */
98#undef HAVE_OPENSSL_EARLYDATA
99#if defined(TLS1_3_VERSION) && !defined(HAVE_BORINGSSL_LIKE)
100#define HAVE_OPENSSL_EARLYDATA
101#endif
103#ifdef LIBRESSL_VERSION_NUMBER
104typedef long ctx_option_t;
105#elif defined(HAVE_BORINGSSL_LIKE)
106typedef uint32_t ctx_option_t;
107#else
108typedef uint64_t ctx_option_t;
109#endif
111struct alpn_spec;
112struct ssl_peer;
113struct Curl_ssl_session;
115struct provider {
116 /* void instead of ENGINE to avoid bleeding OpenSSL into this header */
117 void *engine;
118 /* void instead of OSSL_PROVIDER */
119 void *provider;
120 void *baseprov;
121 void *libctx;
122 char *propq; /* for a provider */
123 BIT(provider_loaded);
124};
126/* Struct to hold a curl OpenSSL instance */
127struct ossl_ctx {
128 /* these ones requires specific SSL-types */
129 SSL_CTX *ssl_ctx;
130 SSL *ssl;
131 BIO_METHOD *bio_method;
132 struct provider p;
133 CURLcode io_result; /* result of last BIO cfilter operation */
134 /* blocked writes need to retry with same length, remember it */
135 int blocked_ssl_write_len;
136#if !defined(HAVE_KEYLOG_UPSTREAM) && !defined(HAVE_KEYLOG_CALLBACK)
137 /* Set to true once a valid keylog entry has been created to avoid dupes.
138 This is a bool and not a bitfield because it is passed by address. */
139 bool keylog_done;
140#endif
141 BIT(x509_store_setup); /* x509 store has been set up */
142 BIT(store_is_empty); /* no certs/paths/blobs in x509 store */
143 BIT(reused_session); /* session-ID was reused for this */
144#ifdef USE_APPLE_SECTRUST
145 BIT(sectrust_verified); /* peer was verified by sectrust */
146 BIT(sectrust_session); /* session from sectrust verified peer */
147#endif
148};
150size_t Curl_ossl_version(char *buffer, size_t size);
152typedef CURLcode Curl_ossl_ctx_setup_cb(struct Curl_cfilter *cf,
153 struct Curl_easy *data,
154 void *user_data);
156typedef int Curl_ossl_new_session_cb(SSL *ssl, SSL_SESSION *ssl_sessionid);
157typedef CURLcode Curl_ossl_init_session_reuse_cb(struct Curl_cfilter *cf,
158 struct Curl_easy *data,
159 struct alpn_spec *alpns,
160 struct Curl_ssl_session *scs,
161 bool *do_early_data);
163CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx,
164 struct Curl_cfilter *cf,
165 struct Curl_easy *data,
166 struct ssl_peer *peer,
167 const struct alpn_spec *alpns_requested,
168 Curl_ossl_ctx_setup_cb *cb_setup,
169 void *cb_user_data,
170 Curl_ossl_new_session_cb *cb_new_session,
171 void *ssl_user_data,
172 Curl_ossl_init_session_reuse_cb *sess_reuse_cb);
174#ifndef HAVE_OPENSSL3
175#define SSL_get1_peer_certificate SSL_get_peer_certificate
176#endif
178extern const struct Curl_ssl Curl_ssl_openssl;
180/**
181 * Setup the OpenSSL X509_STORE in `ssl_ctx` for the cfilter `cf` and
182 * easy handle `data`. Allows reuse of a shared cache if suitable
183 * and configured.
184 */
185CURLcode Curl_ssl_setup_x509_store(struct Curl_cfilter *cf,
186 struct Curl_easy *data,
187 struct ossl_ctx *octx);
189CURLcode Curl_ossl_ctx_configure(struct Curl_cfilter *cf,
190 struct Curl_easy *data,
191 SSL_CTX *ssl_ctx);
193/*
194 * Add a new session to the cache. Takes ownership of the session.
195 */
196CURLcode Curl_ossl_add_session(struct Curl_cfilter *cf,
197 struct Curl_easy *data,
198 struct ossl_ctx *octx,
199 const char *ssl_peer_key,
200 SSL_SESSION *session,
201 const char *alpn,
202 unsigned char *quic_tp,
203 size_t quic_tp_len,
204 struct Curl_ssl_session **psession);
206/*
207 * Get the server cert, verify it and show it, etc., only call failf() if
208 * SSL config verifypeer or -host is set. Otherwise all this is for
209 * informational purposes only!
210 */
211CURLcode Curl_ossl_check_peer_cert(struct Curl_cfilter *cf,
212 struct Curl_easy *data,
213 struct ossl_ctx *octx,
214 struct ssl_peer *peer);
216/* Report properties of a successful handshake */
217void Curl_ossl_report_handshake(struct Curl_easy *data, struct ossl_ctx *octx);
219void Curl_osslctx_cleanup(struct ossl_ctx *octx);
221#endif /* USE_OPENSSL */
222#endif /* HEADER_CURL_SSLUSE_H */
Diagnostics4 git calls · 27 ms
CallStatusSizeTime027 ms
discover200152 B2 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=152 git.server.agent=gitty/1.0 git.server.object_format=sha1 git.server.caps=agent ls-refs fetch object-format git.server.fetch=shallow filter sideband-all git.protocol.version=2 git.pkt.frames=8 git.pkt.data=6 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=152 git.pkt.payload.max=34
ls-refs200149 B · hit2 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=2 git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=149 git.pkt.payload.max=78 git.ls_refs.count=2 git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=3 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=blob:none git.fetch.filter.requested=tree:0 git.fetch.filter.fallback=blob:none git.fetch.filter.learned=false git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=10 git.pkt.data=8 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=293470 git.pkt.payload.max=65516 git.sideband.band1.bytes=293354 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=87 git.pack.bytes=293354 git.pack.ofs_delta=0 git.pack.ref_delta=1 git.pack.chain.max=1 git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0 git.pack.full=86Open pack map
fetch2003.0 KiB · hit22 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=22 git.response.bytes=3077 git.response.cache=HIT git.response.duration_ms=22 git.fetch.wants=fed557518df32e06f990443fbf6975787a2752f6 git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=3077 git.pkt.payload.max=3056 git.sideband.band1.bytes=3055 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
- Ref
- refs/heads/master
- Commit
- 31c911efe5652725e930f4d2e60c9060e5f6646d
- cf-ray
- a5e317597947cf5b
- Request
- 0cbc0637…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format