1 | #ifndef HEADER_CURL_VTLS_H
|
---|
2 | #define HEADER_CURL_VTLS_H
|
---|
3 | /***************************************************************************
|
---|
4 | * _ _ ____ _
|
---|
5 | * Project ___| | | | _ \| |
|
---|
6 | * / __| | | | |_) | |
|
---|
7 | * | (__| |_| | _ <| |___
|
---|
8 | * \___|\___/|_| \_\_____|
|
---|
9 | *
|
---|
10 | * Copyright (C) 1998 - 2022, Daniel Stenberg, <[email protected]>, 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"
|
---|
27 |
|
---|
28 | struct connectdata;
|
---|
29 | struct ssl_config_data;
|
---|
30 | struct ssl_connect_data;
|
---|
31 | struct ssl_primary_config;
|
---|
32 | struct Curl_ssl_session;
|
---|
33 |
|
---|
34 | #define SSLSUPP_CA_PATH (1<<0) /* supports CAPATH */
|
---|
35 | #define SSLSUPP_CERTINFO (1<<1) /* supports CURLOPT_CERTINFO */
|
---|
36 | #define SSLSUPP_PINNEDPUBKEY (1<<2) /* supports CURLOPT_PINNEDPUBLICKEY */
|
---|
37 | #define SSLSUPP_SSL_CTX (1<<3) /* supports CURLOPT_SSL_CTX */
|
---|
38 | #define SSLSUPP_HTTPS_PROXY (1<<4) /* supports access via HTTPS proxies */
|
---|
39 | #define SSLSUPP_TLS13_CIPHERSUITES (1<<5) /* supports TLS 1.3 ciphersuites */
|
---|
40 | #define SSLSUPP_CAINFO_BLOB (1<<6)
|
---|
41 |
|
---|
42 | #define ALPN_ACCEPTED "ALPN: server accepted "
|
---|
43 |
|
---|
44 | #define VTLS_INFOF_NO_ALPN \
|
---|
45 | "ALPN: server did not agree on a protocol. Uses default."
|
---|
46 | #define VTLS_INFOF_ALPN_OFFER_1STR \
|
---|
47 | "ALPN: offers %s"
|
---|
48 | #define VTLS_INFOF_ALPN_ACCEPTED_1STR \
|
---|
49 | ALPN_ACCEPTED "%s"
|
---|
50 | #define VTLS_INFOF_ALPN_ACCEPTED_LEN_1STR \
|
---|
51 | ALPN_ACCEPTED "%.*s"
|
---|
52 |
|
---|
53 | /* Curl_multi SSL backend-specific data; declared differently by each SSL
|
---|
54 | backend */
|
---|
55 | struct multi_ssl_backend_data;
|
---|
56 |
|
---|
57 | CURLsslset Curl_init_sslset_nolock(curl_sslbackend id, const char *name,
|
---|
58 | const curl_ssl_backend ***avail);
|
---|
59 |
|
---|
60 | #ifndef MAX_PINNED_PUBKEY_SIZE
|
---|
61 | #define MAX_PINNED_PUBKEY_SIZE 1048576 /* 1MB */
|
---|
62 | #endif
|
---|
63 |
|
---|
64 | #ifndef CURL_SHA256_DIGEST_LENGTH
|
---|
65 | #define CURL_SHA256_DIGEST_LENGTH 32 /* fixed size */
|
---|
66 | #endif
|
---|
67 |
|
---|
68 | /* see https://www.iana.org/assignments/tls-extensiontype-values/ */
|
---|
69 | #define ALPN_HTTP_1_1_LENGTH 8
|
---|
70 | #define ALPN_HTTP_1_1 "http/1.1"
|
---|
71 | #define ALPN_H2_LENGTH 2
|
---|
72 | #define ALPN_H2 "h2"
|
---|
73 |
|
---|
74 |
|
---|
75 | char *Curl_ssl_snihost(struct Curl_easy *data, const char *host, size_t *olen);
|
---|
76 | bool Curl_ssl_config_matches(struct ssl_primary_config *data,
|
---|
77 | struct ssl_primary_config *needle);
|
---|
78 | bool Curl_clone_primary_ssl_config(struct ssl_primary_config *source,
|
---|
79 | struct ssl_primary_config *dest);
|
---|
80 | void Curl_free_primary_ssl_config(struct ssl_primary_config *sslc);
|
---|
81 |
|
---|
82 | curl_sslbackend Curl_ssl_backend(void);
|
---|
83 |
|
---|
84 | #ifdef USE_SSL
|
---|
85 | int Curl_ssl_init(void);
|
---|
86 | void Curl_ssl_cleanup(void);
|
---|
87 | /* tell the SSL stuff to close down all open information regarding
|
---|
88 | connections (and thus session ID caching etc) */
|
---|
89 | void Curl_ssl_close_all(struct Curl_easy *data);
|
---|
90 | CURLcode Curl_ssl_set_engine(struct Curl_easy *data, const char *engine);
|
---|
91 | /* Sets engine as default for all SSL operations */
|
---|
92 | CURLcode Curl_ssl_set_engine_default(struct Curl_easy *data);
|
---|
93 | struct curl_slist *Curl_ssl_engines_list(struct Curl_easy *data);
|
---|
94 |
|
---|
95 | /* init the SSL session ID cache */
|
---|
96 | CURLcode Curl_ssl_initsessions(struct Curl_easy *, size_t);
|
---|
97 | void Curl_ssl_version(char *buffer, size_t size);
|
---|
98 | int Curl_ssl_check_cxn(struct Curl_easy *data, struct connectdata *conn);
|
---|
99 |
|
---|
100 | /* Certificate information list handling. */
|
---|
101 |
|
---|
102 | void Curl_ssl_free_certinfo(struct Curl_easy *data);
|
---|
103 | CURLcode Curl_ssl_init_certinfo(struct Curl_easy *data, int num);
|
---|
104 | CURLcode Curl_ssl_push_certinfo_len(struct Curl_easy *data, int certnum,
|
---|
105 | const char *label, const char *value,
|
---|
106 | size_t valuelen);
|
---|
107 | CURLcode Curl_ssl_push_certinfo(struct Curl_easy *data, int certnum,
|
---|
108 | const char *label, const char *value);
|
---|
109 |
|
---|
110 | /* Functions to be used by SSL library adaptation functions */
|
---|
111 |
|
---|
112 | /* Lock session cache mutex.
|
---|
113 | * Call this before calling other Curl_ssl_*session* functions
|
---|
114 | * Caller should unlock this mutex as soon as possible, as it may block
|
---|
115 | * other SSL connection from making progress.
|
---|
116 | * The purpose of explicitly locking SSL session cache data is to allow
|
---|
117 | * individual SSL engines to manage session lifetime in their specific way.
|
---|
118 | */
|
---|
119 | void Curl_ssl_sessionid_lock(struct Curl_easy *data);
|
---|
120 |
|
---|
121 | /* Unlock session cache mutex */
|
---|
122 | void Curl_ssl_sessionid_unlock(struct Curl_easy *data);
|
---|
123 |
|
---|
124 | /* Kill a single session ID entry in the cache
|
---|
125 | * Sessionid mutex must be locked (see Curl_ssl_sessionid_lock).
|
---|
126 | * This will call engine-specific curlssl_session_free function, which must
|
---|
127 | * take sessionid object ownership from sessionid cache
|
---|
128 | * (e.g. decrement refcount).
|
---|
129 | */
|
---|
130 | void Curl_ssl_kill_session(struct Curl_ssl_session *session);
|
---|
131 | /* delete a session from the cache
|
---|
132 | * Sessionid mutex must be locked (see Curl_ssl_sessionid_lock).
|
---|
133 | * This will call engine-specific curlssl_session_free function, which must
|
---|
134 | * take sessionid object ownership from sessionid cache
|
---|
135 | * (e.g. decrement refcount).
|
---|
136 | */
|
---|
137 | void Curl_ssl_delsessionid(struct Curl_easy *data, void *ssl_sessionid);
|
---|
138 |
|
---|
139 | /* get N random bytes into the buffer */
|
---|
140 | CURLcode Curl_ssl_random(struct Curl_easy *data, unsigned char *buffer,
|
---|
141 | size_t length);
|
---|
142 | /* Check pinned public key. */
|
---|
143 | CURLcode Curl_pin_peer_pubkey(struct Curl_easy *data,
|
---|
144 | const char *pinnedpubkey,
|
---|
145 | const unsigned char *pubkey, size_t pubkeylen);
|
---|
146 |
|
---|
147 | bool Curl_ssl_cert_status_request(void);
|
---|
148 |
|
---|
149 | bool Curl_ssl_false_start(struct Curl_easy *data);
|
---|
150 |
|
---|
151 | void Curl_free_multi_ssl_backend_data(struct multi_ssl_backend_data *mbackend);
|
---|
152 |
|
---|
153 | #define SSL_SHUTDOWN_TIMEOUT 10000 /* ms */
|
---|
154 |
|
---|
155 | CURLcode Curl_ssl_cfilter_add(struct Curl_easy *data,
|
---|
156 | struct connectdata *conn,
|
---|
157 | int sockindex);
|
---|
158 |
|
---|
159 | CURLcode Curl_ssl_cfilter_remove(struct Curl_easy *data,
|
---|
160 | int sockindex);
|
---|
161 |
|
---|
162 | #ifndef CURL_DISABLE_PROXY
|
---|
163 | CURLcode Curl_ssl_cfilter_proxy_add(struct Curl_easy *data,
|
---|
164 | struct connectdata *conn,
|
---|
165 | int sockindex);
|
---|
166 | #endif /* !CURL_DISABLE_PROXY */
|
---|
167 |
|
---|
168 | /**
|
---|
169 | * Get the SSL configuration that is used on the connection.
|
---|
170 | * This returns NULL if no SSL is configured.
|
---|
171 | * Otherwise it returns the config of the first (highest) one that is
|
---|
172 | * either connected, in handshake or about to start
|
---|
173 | * (e.g. all filters below it are connected). If SSL filters are present,
|
---|
174 | * but neither can start operating, return the config of the lowest one
|
---|
175 | * that will first come into effect when connecting.
|
---|
176 | */
|
---|
177 | struct ssl_config_data *Curl_ssl_get_config(struct Curl_easy *data,
|
---|
178 | int sockindex);
|
---|
179 |
|
---|
180 | /**
|
---|
181 | * Get the primary SSL configuration from the connection.
|
---|
182 | * This returns NULL if no SSL is configured.
|
---|
183 | * Otherwise it returns the config of the first (highest) one that is
|
---|
184 | * either connected, in handshake or about to start
|
---|
185 | * (e.g. all filters below it are connected). If SSL filters are present,
|
---|
186 | * but neither can start operating, return the config of the lowest one
|
---|
187 | * that will first come into effect when connecting.
|
---|
188 | */
|
---|
189 | struct ssl_primary_config *
|
---|
190 | Curl_ssl_get_primary_config(struct Curl_easy *data,
|
---|
191 | struct connectdata *conn,
|
---|
192 | int sockindex);
|
---|
193 |
|
---|
194 | /**
|
---|
195 | * True iff the underlying SSL implementation supports the option.
|
---|
196 | * Option is one of the defined SSLSUPP_* values.
|
---|
197 | * `data` maybe NULL for the features of the default implementation.
|
---|
198 | */
|
---|
199 | bool Curl_ssl_supports(struct Curl_easy *data, int ssl_option);
|
---|
200 |
|
---|
201 | /**
|
---|
202 | * Get the internal ssl instance (like OpenSSL's SSL*) from the filter
|
---|
203 | * chain at `sockindex` of type specified by `info`.
|
---|
204 | * For `n` == 0, the first active (top down) instance is returned.
|
---|
205 | * 1 gives the second active, etc.
|
---|
206 | * NULL is returned when no active SSL filter is present.
|
---|
207 | */
|
---|
208 | void *Curl_ssl_get_internals(struct Curl_easy *data, int sockindex,
|
---|
209 | CURLINFO info, int n);
|
---|
210 |
|
---|
211 | #else /* if not USE_SSL */
|
---|
212 |
|
---|
213 | /* When SSL support is not present, just define away these function calls */
|
---|
214 | #define Curl_ssl_init() 1
|
---|
215 | #define Curl_ssl_cleanup() Curl_nop_stmt
|
---|
216 | #define Curl_ssl_close_all(x) Curl_nop_stmt
|
---|
217 | #define Curl_ssl_set_engine(x,y) CURLE_NOT_BUILT_IN
|
---|
218 | #define Curl_ssl_set_engine_default(x) CURLE_NOT_BUILT_IN
|
---|
219 | #define Curl_ssl_engines_list(x) NULL
|
---|
220 | #define Curl_ssl_initsessions(x,y) CURLE_OK
|
---|
221 | #define Curl_ssl_check_cxn(d,x) 0
|
---|
222 | #define Curl_ssl_free_certinfo(x) Curl_nop_stmt
|
---|
223 | #define Curl_ssl_kill_session(x) Curl_nop_stmt
|
---|
224 | #define Curl_ssl_random(x,y,z) ((void)x, CURLE_NOT_BUILT_IN)
|
---|
225 | #define Curl_ssl_cert_status_request() FALSE
|
---|
226 | #define Curl_ssl_false_start(a) FALSE
|
---|
227 | #define Curl_ssl_get_internals(a,b,c,d) NULL
|
---|
228 | #define Curl_ssl_supports(a,b) FALSE
|
---|
229 | #define Curl_ssl_cfilter_add(a,b,c) CURLE_NOT_BUILT_IN
|
---|
230 | #define Curl_ssl_cfilter_proxy_add(a,b,c) CURLE_NOT_BUILT_IN
|
---|
231 | #define Curl_ssl_get_config(a,b) NULL
|
---|
232 | #define Curl_ssl_cfilter_remove(a,b) CURLE_OK
|
---|
233 | #endif
|
---|
234 |
|
---|
235 | #endif /* HEADER_CURL_VTLS_H */
|
---|