1 #ifndef HEADER_CURL_VQUIC_TLS_H 2 #define HEADER_CURL_VQUIC_TLS_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 27 #include "curl_setup.h" 28 #include "bufq.h" 29 #include "vtls/openssl.h" 30 31 #if defined(USE_HTTP3) && \ 32 (defined(USE_OPENSSL) || defined(USE_GNUTLS) || defined(USE_WOLFSSL)) 33 34 struct curl_tls_ctx { 35 #ifdef USE_OPENSSL 36 struct ossl_ctx ossl; 37 #elif defined(USE_GNUTLS) 38 struct gtls_ctx gtls; 39 #elif defined(USE_WOLFSSL) 40 WOLFSSL_CTX *ssl_ctx; 41 WOLFSSL *ssl; 42 #endif 43 }; 44 45 /** 46 * Callback passed to `Curl_vquic_tls_init()` that can 47 * do early initializations on the not otherwise configured TLS 48 * instances created. This varies by TLS backend: 49 * - openssl/wolfssl: SSL_CTX* has just been created 50 * - gnutls: gtls_client_init() has run 51 */ 52 typedef CURLcode Curl_vquic_tls_ctx_setup(struct Curl_cfilter *cf, 53 struct Curl_easy *data, 54 void *cb_user_data); 55 56 /** 57 * Initialize the QUIC TLS instances based of the SSL configurations 58 * for the connection filter, transfer and peer. 59 * @param ctx the TLS context to initialize 60 * @param cf the connection filter involved 61 * @param data the transfer involved 62 * @param peer the peer that will be connected to 63 * @param alpn the ALPN string in protocol format ((len+bytes+)+), 64 * may be NULL 65 * @param alpn_len the overall number of bytes in `alpn` 66 * @param cb_setup optional callback for very early TLS config 67 ± @param cb_user_data user_data param for callback 68 * @param ssl_user_data optional pointer to set in TLS application context 69 */ 70 CURLcode Curl_vquic_tls_init(struct curl_tls_ctx *ctx, 71 struct Curl_cfilter *cf, 72 struct Curl_easy *data, 73 struct ssl_peer *peer, 74 const char *alpn, size_t alpn_len, 75 Curl_vquic_tls_ctx_setup *cb_setup, 76 void *cb_user_data, 77 void *ssl_user_data); 78 79 /** 80 * Cleanup all data that has been initialized. 81 */ 82 void Curl_vquic_tls_cleanup(struct curl_tls_ctx *ctx); 83 84 CURLcode Curl_vquic_tls_before_recv(struct curl_tls_ctx *ctx, 85 struct Curl_cfilter *cf, 86 struct Curl_easy *data); 87 88 /** 89 * After the QUIC basic handshake has been, verify that the peer 90 * (and its certificate) fulfill our requirements. 91 */ 92 CURLcode Curl_vquic_tls_verify_peer(struct curl_tls_ctx *ctx, 93 struct Curl_cfilter *cf, 94 struct Curl_easy *data, 95 struct ssl_peer *peer); 96 97 #endif /* !USE_HTTP3 && (USE_OPENSSL || USE_GNUTLS || USE_WOLFSSL) */ 98 99 #endif /* HEADER_CURL_VQUIC_TLS_H */ 100