Botan 3.4.0
Crypto and TLS for C&
tls_client.h
Go to the documentation of this file.
1/*
2* TLS Client
3* (C) 2004-2011 Jack Lloyd
4* 2016 Matthias Gierlings
5* 2021 Elektrobit Automotive GmbH
6* 2022 René Meusel, Hannes Rantzsch - neXenio GmbH
7*
8* Botan is released under the Simplified BSD License (see license.txt)
9*/
10
11#ifndef BOTAN_TLS_CLIENT_H_
12#define BOTAN_TLS_CLIENT_H_
13
14#include <botan/credentials_manager.h>
15#include <botan/tls_channel.h>
16#include <botan/tls_policy.h>
17#include <memory>
18#include <vector>
19
20namespace Botan::TLS {
21
22class Channel_Impl;
23class Handshake_IO;
24
25/**
26* SSL/TLS Client
27*/
28class BOTAN_PUBLIC_API(2, 0) Client final : public Channel {
29 public:
30 /**
31 * Set up a new TLS client session
32 *
33 * @param callbacks contains a set of callback function references
34 * required by the TLS client.
35 *
36 * @param session_manager manages session state
37 *
38 * @param creds manages application/user credentials
39 *
40 * @param policy specifies other connection policy information
41 *
42 * @param rng a random number generator
43 *
44 * @param server_info is identifying information about the TLS server
45 *
46 * @param offer_version specifies which version we will offer
47 * to the TLS server.
48 *
49 * @param next_protocols specifies protocols to advertise with ALPN
50 *
51 * @param reserved_io_buffer_size This many bytes of memory will
52 * be preallocated for the read and write buffers. Smaller
53 * values just mean reallocations and copies are more likely.
54 */
55 Client(const std::shared_ptr<Callbacks>& callbacks,
56 const std::shared_ptr<Session_Manager>& session_manager,
57 const std::shared_ptr<Credentials_Manager>& creds,
58 const std::shared_ptr<const Policy>& policy,
59 const std::shared_ptr<RandomNumberGenerator>& rng,
61 Protocol_Version offer_version = Protocol_Version::latest_tls_version(),
62 const std::vector<std::string>& next_protocols = {},
63 size_t reserved_io_buffer_size = TLS::Client::IO_BUF_DEFAULT_SIZE);
64
65 ~Client() override;
66
67 /**
68 * @return network protocol as advertised by the TLS server, if server sent the ALPN extension
69 */
70 std::string application_protocol() const override;
71
72 size_t from_peer(std::span<const uint8_t> data) override;
73
74 bool is_handshake_complete() const override;
75
76 bool is_active() const override;
77
78 bool is_closed() const override;
79
80 bool is_closed_for_reading() const override;
81 bool is_closed_for_writing() const override;
82
83 std::vector<X509_Certificate> peer_cert_chain() const override;
84 std::shared_ptr<const Public_Key> peer_raw_public_key() const override;
85 std::optional<std::string> external_psk_identity() const override;
86
87 SymmetricKey key_material_export(std::string_view label, std::string_view context, size_t length) const override;
88
89 void renegotiate(bool force_full_renegotiation = false) override;
90
91 void update_traffic_keys(bool request_peer_update = false) override;
92
93 bool secure_renegotiation_supported() const override;
94
95 void to_peer(std::span<const uint8_t> data) override;
96
97 void send_alert(const Alert& alert) override;
98
99 void send_warning_alert(Alert::Type type) override;
100
101 void send_fatal_alert(Alert::Type type) override;
102
103 void close() override;
104
105 bool timeout_check() override;
106
107 private:
108 size_t downgrade();
109
110 private:
111 std::unique_ptr<Channel_Impl> m_impl;
112};
113} // namespace Botan::TLS
114
115#endif
~Client() override
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition compiler.h:31