9 #include <aws/io/tls_channel_handler.h>
14 struct aws_tls_ctx_options;
23 class TlsContextPkcs11Options;
24 struct TlsConnectionInfo;
25 enum class CertificateSource;
44 TlsContextOptions(const TlsContextOptions &) noexcept = delete;
45 TlsContextOptions &operator=(const TlsContextOptions &) noexcept = delete;
46 TlsContextOptions(TlsContextOptions &&) noexcept;
47 TlsContextOptions &operator=(TlsContextOptions &&) noexcept;
52 explicit operator
bool() const noexcept {
return m_isInit; }
77 const
char *cert_path,
78 const
char *pkey_path,
123 const
char *pkcs12_path,
124 const
char *pkcs12_pwd,
137 bool SetKeychainPath(
ByteCursor &keychain_path) noexcept;
151 const
char *windowsCertStorePath,
158 static
bool IsAlpnSupported() noexcept;
165 bool SetAlpnList(const
char *alpnList) noexcept;
175 void SetVerifyPeer(
bool verifyPeer) noexcept;
190 void SetNoCertificateRevocation(
bool noCertificateRevocation) noexcept;
196 void SetMinimumTlsVersion(aws_tls_versions minimumTlsVersion);
202 void SetTlsCipherPreference(aws_tls_cipher_pref cipher_pref);
212 bool OverrideDefaultTrustStore(const
char *caPath, const
char *caFile) noexcept;
218 bool OverrideDefaultTrustStore(const
ByteCursor &ca) noexcept;
221 const aws_tls_ctx_options *GetUnderlyingHandle() const noexcept
223 return m_isInit ? &m_options :
nullptr;
227 aws_tls_ctx_options m_options;
228 aws_tls_versions m_metricsTlsVersion;
229 aws_tls_cipher_pref m_metricsCipherPref;
231 CertificateSource m_metricsCertificateSource;
233 bool m_isInit =
false;
249 const std::shared_ptr<Pkcs11Lib> &pkcs11Lib,
258 void SetUserPin(
const String &pin) noexcept;
266 void SetSlotId(
const uint64_t
id) noexcept;
274 void SetTokenLabel(
const String &label) noexcept;
283 void SetPrivateKeyObjectLabel(
const String &label) noexcept;
291 void SetCertificateFilePath(
const String &path) noexcept;
299 void SetCertificateFileContents(
const String &contents) noexcept;
302 aws_tls_ctx_pkcs11_options GetUnderlyingHandle()
const noexcept;
305 std::shared_ptr<Pkcs11Lib> m_pkcs11Lib;
332 bool SetServerName(
ByteCursor &serverName) noexcept;
340 bool SetAlpnList(
const char *alpnList) noexcept;
345 explicit operator bool() const noexcept {
return isValid(); }
353 const aws_tls_connection_options *GetUnderlyingHandle() const noexcept
355 return m_isInit ? &m_tls_connection_options :
nullptr;
359 TlsConnectionInfo GetTlsConnectionInfo() const noexcept;
362 bool isValid() const noexcept {
return m_isInit; }
366 TlsConnectionOptions(
369 CertificateSource metricsCertificateSource,
370 aws_tls_versions metricsTlsVersion = AWS_IO_TLS_VER_SYS_DEFAULTS,
371 aws_tls_cipher_pref metricsCipherPref = AWS_IO_TLS_CIPHER_PREF_SYSTEM_DEFAULT) noexcept;
372 aws_tls_connection_options m_tls_connection_options;
373 aws_allocator *m_allocator =
nullptr;
374 int m_lastError = AWS_ERROR_SUCCESS;
375 bool m_isInit = false;
378 CertificateSource m_metricsCertificateSource;
379 aws_tls_versions m_metricsTlsVersion;
380 aws_tls_cipher_pref m_metricsCipherPref;
392 TlsContext() noexcept;
394 ~TlsContext() =
default;
395 TlsContext(
const TlsContext &) noexcept =
default;
396 TlsContext &operator=(
const TlsContext &) noexcept =
default;
397 TlsContext(TlsContext &&) noexcept =
default;
398 TlsContext &operator=(TlsContext &&) noexcept =
default;
409 explicit operator bool() const noexcept {
return isValid(); }
417 aws_tls_ctx *GetUnderlyingHandle() const noexcept {
return m_ctx.get(); }
420 bool isValid() const noexcept {
return m_ctx && m_initializationError == AWS_ERROR_SUCCESS; }
422 std::shared_ptr<aws_tls_ctx> m_ctx;
423 int m_initializationError;
425 CertificateSource m_metricsCertificateSource;
426 aws_tls_versions m_metricsTlsVersion;
427 aws_tls_cipher_pref m_metricsCipherPref;
445 virtual String GetProtocol()
const = 0;
449 struct aws_channel_slot *slot,
450 const struct aws_tls_connection_options &options,
458 void CompleteTlsNegotiation(
int errorCode);
461 aws_tls_on_negotiation_result_fn *m_OnNegotiationResult;
464 aws_byte_buf m_protocolByteBuf;
465 friend aws_byte_buf(::aws_tls_handler_protocol)(aws_channel_handler *);
481 virtual void StartNegotiation() = 0;
485 struct aws_channel_slot *slot,
486 const struct aws_tls_connection_options &options,
491 struct aws_channel_slot *slot,
492 const struct aws_tls_connection_options &options,
Definition: TlsOptions.h:474
Definition: TlsOptions.h:389
Definition: ChannelHandler.h:41
#define AWS_CRT_CPP_API
Definition: Exports.h:36
int LastError() const noexcept
Definition: TlsOptions.h:350
std::basic_string< char, std::char_traits< char >, StlAllocator< char >> String
Definition: Types.h:45
aws_allocator Allocator
Definition: Allocator.h:14
aws_byte_cursor ByteCursor
Definition: Types.h:31
std::function< bool()> IsTlsAlpnSupportedCallback
Definition: TlsOptions.h:432
Definition: TlsOptions.h:37
TlsMode
Definition: TlsOptions.h:27
AWS_CRT_CPP_API Allocator * ApiAllocator() noexcept
Definition: Allocator.cpp:24
std::function< void(void *)> DeleteTlsContextImplCallback
Definition: TlsOptions.h:431
std::function< std::shared_ptr< ClientTlsChannelHandler >(struct aws_channel_slot *slot, const struct aws_tls_connection_options &options, Allocator *allocator)> NewClientTlsHandlerCallback
Definition: TlsOptions.h:493
AWS_CRT_CPP_API int LastError() noexcept
Definition: Api.cpp:469
std::function< void *(TlsContextOptions &, TlsMode, Allocator *)> NewTlsContextImplCallback
Definition: TlsOptions.h:430
Definition: TlsOptions.h:241
Definition: TlsOptions.h:317
int GetInitializationError() const noexcept
Definition: TlsOptions.h:414
Definition: Allocator.h:10
Definition: TlsOptions.h:437