9#include <aws/io/tls_channel_handler.h>
14struct aws_tls_ctx_options;
23 class TlsContextPkcs11Options;
24 struct TlsConnectionInfo;
25 enum class CertificateSource;
52 explicit operator
bool() const noexcept {
return m_isInit; }
77 const
char *cert_path,
78 const
char *pkey_path,
79 Allocator *allocator = ApiAllocator()) noexcept;
95 Allocator *allocator = ApiAllocator()) noexcept;
108 Allocator *allocator = ApiAllocator()) noexcept;
123 const
char *pkcs12_path,
124 const
char *pkcs12_pwd,
125 Allocator *allocator = ApiAllocator()) noexcept;
137 bool SetKeychainPath(
ByteCursor &keychain_path) noexcept;
151 const
char *windowsCertStorePath,
152 Allocator *allocator = ApiAllocator()) noexcept;
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(
368 Allocator *allocator,
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;
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;
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 *);
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,
#define AWS_CRT_CPP_API
Definition Exports.h:36
Definition ChannelHandler.h:47
Definition TlsOptions.h:475
virtual void StartNegotiation()=0
Definition TlsOptions.h:438
virtual String GetProtocol() const =0
Definition TlsOptions.h:318
int LastError() const noexcept
Definition TlsOptions.h:350
Definition TlsOptions.h:390
TlsContext(TlsContext &&) noexcept=default
TlsContext & operator=(const TlsContext &) noexcept=default
int GetInitializationError() const noexcept
Definition TlsOptions.h:414
TlsContext(const TlsContext &) noexcept=default
Definition TlsOptions.h:38
Definition TlsOptions.h:242
std::function< void *(TlsContextOptions &, TlsMode, Allocator *)> NewTlsContextImplCallback
Definition TlsOptions.h:430
TlsMode
Definition TlsOptions.h:28
std::function< bool()> IsTlsAlpnSupportedCallback
Definition TlsOptions.h:432
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
std::function< void(void *)> DeleteTlsContextImplCallback
Definition TlsOptions.h:431
aws_byte_cursor ByteCursor
Definition Types.h:31
aws_allocator Allocator
Definition Allocator.h:14
AWS_CRT_CPP_API Allocator * ApiAllocator() noexcept
Definition Allocator.cpp:24
std::basic_string< char, std::char_traits< char >, StlAllocator< char > > String
Definition Types.h:45
AWS_CRT_CPP_API int LastError() noexcept
Definition Api.cpp:469
Definition Allocator.h:11