vquic-tls.h 3.7 KB

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