AWS IoT Device SDK C++ v2  1.34.0
AWS IoT Device SDK C++ v2
Public Member Functions | Static Public Member Functions | List of all members
Aws::Iot::MqttClientConnectionConfigBuilder Class Referencefinal

#include <MqttClient.h>

Public Member Functions

 MqttClientConnectionConfigBuilder ()
 
 MqttClientConnectionConfigBuilder (const char *certPath, const char *pkeyPath, Crt::Allocator *allocator=Crt::ApiAllocator()) noexcept
 
 MqttClientConnectionConfigBuilder (const Crt::ByteCursor &cert, const Crt::ByteCursor &pkey, Crt::Allocator *allocator=Crt::ApiAllocator()) noexcept
 
 MqttClientConnectionConfigBuilder (const Crt::Io::TlsContextPkcs11Options &pkcs11Options, Crt::Allocator *allocator=Crt::ApiAllocator()) noexcept
 
 MqttClientConnectionConfigBuilder (const struct Pkcs12Options &options, Crt::Allocator *allocator=Crt::ApiAllocator()) noexcept
 
 MqttClientConnectionConfigBuilder (const char *windowsCertStorePath, Crt::Allocator *allocator=Crt::ApiAllocator()) noexcept
 
 MqttClientConnectionConfigBuilder (const WebsocketConfig &config, Crt::Allocator *allocator=Crt::ApiAllocator()) noexcept
 
MqttClientConnectionConfigBuilderWithEndpoint (const Crt::String &endpoint)
 
MqttClientConnectionConfigBuilderWithEndpoint (Crt::String &&endpoint)
 
MqttClientConnectionConfigBuilderWithPortOverride (uint32_t port) noexcept
 
MqttClientConnectionConfigBuilderWithCertificateAuthority (const char *caPath) noexcept
 
MqttClientConnectionConfigBuilderWithCertificateAuthority (const Crt::ByteCursor &cert) noexcept
 
MqttClientConnectionConfigBuilderWithTcpKeepAlive () noexcept
 
MqttClientConnectionConfigBuilderWithTcpConnectTimeout (uint32_t connectTimeoutMs) noexcept
 
MqttClientConnectionConfigBuilderWithTcpKeepAliveTimeout (uint16_t keepAliveTimeoutSecs) noexcept
 
MqttClientConnectionConfigBuilderWithTcpKeepAliveInterval (uint16_t keepAliveIntervalSecs) noexcept
 
MqttClientConnectionConfigBuilderWithTcpKeepAliveMaxProbes (uint16_t maxProbes) noexcept
 
MqttClientConnectionConfigBuilderWithMinimumTlsVersion (aws_tls_versions minimumTlsVersion) noexcept
 
MqttClientConnectionConfigBuilderWithHttpProxyOptions (const Crt::Http::HttpClientConnectionProxyOptions &proxyOptions) noexcept
 
MqttClientConnectionConfigBuilderWithMetricsCollection (bool enabled)
 
MqttClientConnectionConfigBuilderWithSdkName (const Crt::String &sdkName)
 
MqttClientConnectionConfigBuilderWithSdkVersion (const Crt::String &sdkVersion)
 
MqttClientConnectionConfigBuilderWithCustomAuthorizer (const Crt::String &username, const Crt::String &authorizerName, const Crt::String &authorizerSignature, const Crt::String &password) noexcept
 
MqttClientConnectionConfigBuilderWithCustomAuthorizer (const Crt::String &username, const Crt::String &authorizerName, const Crt::String &authorizerSignature, const Crt::String &password, const Crt::String &tokenKeyName, const Crt::String &tokenValue) noexcept
 
MqttClientConnectionConfigBuilderWithUsername (const Crt::String &username) noexcept
 
MqttClientConnectionConfigBuilderWithPassword (const Crt::String &password) noexcept
 
MqttClientConnectionConfig Build () noexcept
 
 operator bool () const noexcept
 
int LastError () const noexcept
 

Static Public Member Functions

static MqttClientConnectionConfigBuilder NewDefaultBuilder () noexcept
 

Detailed Description

Represents configuration parameters for building a MqttClientConnectionConfig object. You can use a single instance of this class PER MqttClientConnectionConfig you want to generate. If you want to generate a config for a different endpoint or port etc... you need a new instance of this class.

Constructor & Destructor Documentation

◆ MqttClientConnectionConfigBuilder() [1/7]

Aws::Iot::MqttClientConnectionConfigBuilder::MqttClientConnectionConfigBuilder ( )

◆ MqttClientConnectionConfigBuilder() [2/7]

Aws::Iot::MqttClientConnectionConfigBuilder::MqttClientConnectionConfigBuilder ( const char *  certPath,
const char *  pkeyPath,
Crt::Allocator allocator = Crt::ApiAllocator() 
)
noexcept

Sets the builder up for MTLS using certPath and pkeyPath. These are files on disk and must be in the PEM format.

Parameters
certPathpath to the X509 certificate (pem file) to use
pkeyPathpath to the private key (pem file) to use
allocatormemory allocator to use

◆ MqttClientConnectionConfigBuilder() [3/7]

Aws::Iot::MqttClientConnectionConfigBuilder::MqttClientConnectionConfigBuilder ( const Crt::ByteCursor cert,
const Crt::ByteCursor pkey,
Crt::Allocator allocator = Crt::ApiAllocator() 
)
noexcept

Sets the builder up for MTLS using cert and pkey. These are in-memory buffers and must be in the PEM format.

Parameters
certbuffer containing the X509 certificate in a PEM format
pkeybuffer containing the private key in a PEM format
allocatormemory allocator to use

◆ MqttClientConnectionConfigBuilder() [4/7]

Aws::Iot::MqttClientConnectionConfigBuilder::MqttClientConnectionConfigBuilder ( const Crt::Io::TlsContextPkcs11Options pkcs11Options,
Crt::Allocator allocator = Crt::ApiAllocator() 
)
noexcept

Sets the builder up for MTLS, using a PKCS#11 library for private key operations.

NOTE: This only works on Unix devices.

Parameters
pkcs11OptionsPKCS#11 options
allocatormemory allocator to use

◆ MqttClientConnectionConfigBuilder() [5/7]

Aws::Iot::MqttClientConnectionConfigBuilder::MqttClientConnectionConfigBuilder ( const struct Pkcs12Options options,
Crt::Allocator allocator = Crt::ApiAllocator() 
)
noexcept

Sets the builder up for MTLS using a PKCS12 file and password. These are files on disk and must be in the PEM format.

NOTE: This only works on MacOS devices.

Parameters
optionsThe PKCS12 options to use. Has to contain a PKCS12 filepath and password.
allocatormemory allocator to use

◆ MqttClientConnectionConfigBuilder() [6/7]

Aws::Iot::MqttClientConnectionConfigBuilder::MqttClientConnectionConfigBuilder ( const char *  windowsCertStorePath,
Crt::Allocator allocator = Crt::ApiAllocator() 
)
noexcept

Sets the builder up for MTLS, using a certificate in a Windows certificate store.

NOTE: This only works on Windows.

Parameters
windowsCertStorePathPath to certificate in a Windows certificate store. The path must use backslashes and end with the certificate's thumbprint. Example: CurrentUser\MY\A11F8A9B5DF5B98BA3508FBCA575D09570E0D2C6
allocatormemory allocator to use

◆ MqttClientConnectionConfigBuilder() [7/7]

Aws::Iot::MqttClientConnectionConfigBuilder::MqttClientConnectionConfigBuilder ( const WebsocketConfig config,
Crt::Allocator allocator = Crt::ApiAllocator() 
)
noexcept

Sets the builder up for Websocket connection.

Parameters
configwebsocket configuration information
allocatormemory allocator to use

Member Function Documentation

◆ Build()

MqttClientConnectionConfig Aws::Iot::MqttClientConnectionConfigBuilder::Build ( )
noexcept

Builds a client configuration object from the set options.

Returns
a new client connection config instance

◆ LastError()

int Aws::Iot::MqttClientConnectionConfigBuilder::LastError ( ) const
inlinenoexcept
Returns
the value of the last aws error encountered by operations on this instance.

◆ NewDefaultBuilder()

MqttClientConnectionConfigBuilder Aws::Iot::MqttClientConnectionConfigBuilder::NewDefaultBuilder ( )
staticnoexcept

Creates a new builder with default Tls options. This requires setting the connection details manually.

Returns
a new builder with default Tls options

◆ operator bool()

Aws::Iot::MqttClientConnectionConfigBuilder::operator bool ( ) const
inlineexplicitnoexcept
Returns
true if the instance is in a valid state, false otherwise.

◆ WithCertificateAuthority() [1/2]

MqttClientConnectionConfigBuilder & Aws::Iot::MqttClientConnectionConfigBuilder::WithCertificateAuthority ( const char *  caPath)
noexcept

Sets the certificate authority for the endpoint you're connecting to. This is a path to a file on disk and must be in PEM format.

Parameters
caPathpath to the CA file in PEM format
Returns
this builder object

◆ WithCertificateAuthority() [2/2]

MqttClientConnectionConfigBuilder & Aws::Iot::MqttClientConnectionConfigBuilder::WithCertificateAuthority ( const Crt::ByteCursor cert)
noexcept

Sets the certificate authority for the endpoint you're connecting to. This is an in-memory buffer and must be in PEM format.

Parameters
certbuffer containing the CA certificate in a PEM format
Returns
this builder object

◆ WithCustomAuthorizer() [1/2]

MqttClientConnectionConfigBuilder & Aws::Iot::MqttClientConnectionConfigBuilder::WithCustomAuthorizer ( const Crt::String username,
const Crt::String authorizerName,
const Crt::String authorizerSignature,
const Crt::String password 
)
noexcept

Sets the custom authorizer settings. This function will modify the username, port, and TLS options.

Parameters
usernameThe username to use with the custom authorizer. If an empty string is passed, it will check to see if a username has already been set (via WithUsername function). If no username is set then no username will be passed with the MQTT connection.
authorizerNameThe name of the custom authorizer. If an empty string is passed, then 'x-amz-customauthorizer-name' will not be added with the MQTT connection.
authorizerSignatureThe signature of the custom authorizer. NOTE: This will NOT work without the token key name and token value, which requires using the non-depreciated API.
passwordThe password to use with the custom authorizer. If null is passed, then no password will be set.
Deprecated:
Please use the full WithCustomAuthorizer function that includes tokenKeyName and tokenValue. This version is left for backwards compatibility purposes.
Returns
this builder object

◆ WithCustomAuthorizer() [2/2]

MqttClientConnectionConfigBuilder & Aws::Iot::MqttClientConnectionConfigBuilder::WithCustomAuthorizer ( const Crt::String username,
const Crt::String authorizerName,
const Crt::String authorizerSignature,
const Crt::String password,
const Crt::String tokenKeyName,
const Crt::String tokenValue 
)
noexcept

Sets the custom authorizer settings. This function will modify the username, port, and TLS options.

Parameters
usernameThe username to use with the custom authorizer. If an empty string is passed, it will check to see if a username has already been set (via WithUsername function). If no username is set then no username will be passed with the MQTT connection.
authorizerNameThe name of the custom authorizer. If an empty string is passed, then 'x-amz-customauthorizer-name' will not be added with the MQTT connection.
authorizerSignatureThe signature of the custom authorizer. If an empty string is passed, then 'x-amz-customauthorizer-signature' will not be added with the MQTT connection. The signature must be based on the private key associated with the custom authorizer. The signature must be base64 encoded.
passwordThe password to use with the custom authorizer. If null is passed, then no password will be set.
tokenKeyNameUsed to extract the custom authorizer token from MQTT username query-string properties. Required if the custom authorizer has signing enabled. It is strongly suggested to URL encode this value; the SDK will not do so for you.
tokenValueAn opaque token value. Required if the custom authorizer has signing enabled. This value must be signed by the private key associated with the custom authorizer and the result placed in the authorizerSignature argument.
Returns
this builder object

◆ WithEndpoint() [1/2]

MqttClientConnectionConfigBuilder & Aws::Iot::MqttClientConnectionConfigBuilder::WithEndpoint ( const Crt::String endpoint)

Sets endpoint to connect to.

Parameters
endpointendpoint to connect to
Returns
this builder object

◆ WithEndpoint() [2/2]

MqttClientConnectionConfigBuilder & Aws::Iot::MqttClientConnectionConfigBuilder::WithEndpoint ( Crt::String &&  endpoint)

Sets endpoint to connect to.

Parameters
endpointendpoint to connect to
Returns
this builder object

◆ WithHttpProxyOptions()

MqttClientConnectionConfigBuilder & Aws::Iot::MqttClientConnectionConfigBuilder::WithHttpProxyOptions ( const Crt::Http::HttpClientConnectionProxyOptions proxyOptions)
noexcept

Sets http proxy options.

Parameters
proxyOptionsproxy configuration options for connection establishment
Returns
this builder object

◆ WithMetricsCollection()

MqttClientConnectionConfigBuilder & Aws::Iot::MqttClientConnectionConfigBuilder::WithMetricsCollection ( bool  enabled)

Whether to send the SDK name and version number in the MQTT CONNECT packet. Default is True.

Parameters
enabledtrue to send SDK version/name in the connect for metrics gathering purposes
Returns
this builder object

◆ WithMinimumTlsVersion()

MqttClientConnectionConfigBuilder & Aws::Iot::MqttClientConnectionConfigBuilder::WithMinimumTlsVersion ( aws_tls_versions  minimumTlsVersion)
noexcept

Sets the minimum tls version that is acceptable for connection establishment

Parameters
minimumTlsVersionminimum tls version allowed in client connections
Returns
this builder object

◆ WithPassword()

MqttClientConnectionConfigBuilder & Aws::Iot::MqttClientConnectionConfigBuilder::WithPassword ( const Crt::String password)
noexcept

Sets password for the connection

Parameters
passwordthe password that will be passed with the MQTT connection
Returns
this builder object

◆ WithPortOverride()

MqttClientConnectionConfigBuilder & Aws::Iot::MqttClientConnectionConfigBuilder::WithPortOverride ( uint32_t  port)
noexcept

Overrides the default port. By default, if ALPN is supported, 443 will be used. Otherwise 8883 will be used. If you specify 443 and ALPN is not supported, we will still attempt to connect over 443 without ALPN.

Parameters
portport to connect to
Returns
this builder object

◆ WithSdkName()

MqttClientConnectionConfigBuilder & Aws::Iot::MqttClientConnectionConfigBuilder::WithSdkName ( const Crt::String sdkName)

Overrides the default SDK Name to send as a metric in the MQTT CONNECT packet.

Parameters
sdkNamestring to use as the SDK name parameter in the connection string
Returns
this builder object

◆ WithSdkVersion()

MqttClientConnectionConfigBuilder & Aws::Iot::MqttClientConnectionConfigBuilder::WithSdkVersion ( const Crt::String sdkVersion)

Overrides the default SDK Version to send as a metric in the MQTT CONNECT packet.

Parameters
sdkVersionstring to use as the SDK version parameter in the connection string
Returns
this builder object

◆ WithTcpConnectTimeout()

MqttClientConnectionConfigBuilder & Aws::Iot::MqttClientConnectionConfigBuilder::WithTcpConnectTimeout ( uint32_t  connectTimeoutMs)
noexcept

TCP option: Sets the connect timeout. Defaults to 3 seconds.

Parameters
connectTimeoutMssocket connection timeout
Returns
this builder object

◆ WithTcpKeepAlive()

MqttClientConnectionConfigBuilder & Aws::Iot::MqttClientConnectionConfigBuilder::WithTcpKeepAlive ( )
noexcept

TCP option: Enables TCP keep alive. Defaults to off.

Returns
this builder object

◆ WithTcpKeepAliveInterval()

MqttClientConnectionConfigBuilder & Aws::Iot::MqttClientConnectionConfigBuilder::WithTcpKeepAliveInterval ( uint16_t  keepAliveIntervalSecs)
noexcept

TCP option: Sets the frequency of sending keep alive probes in seconds once the keep alive timeout expires. Defaults to kernel defaults.

Parameters
keepAliveIntervalSecsthe frequency of sending keep alive probes in seconds once the keep alive timeout expires
Returns
this builder object

◆ WithTcpKeepAliveMaxProbes()

MqttClientConnectionConfigBuilder & Aws::Iot::MqttClientConnectionConfigBuilder::WithTcpKeepAliveMaxProbes ( uint16_t  maxProbes)
noexcept

TCP option: Sets the amount of keep alive probes allowed to fail before the connection is terminated. Defaults to kernel defaults.

Parameters
maxProbesthe amount of keep alive probes allowed to fail before the connection is terminated
Returns
this builder object

◆ WithTcpKeepAliveTimeout()

MqttClientConnectionConfigBuilder & Aws::Iot::MqttClientConnectionConfigBuilder::WithTcpKeepAliveTimeout ( uint16_t  keepAliveTimeoutSecs)
noexcept

TCP option: Sets time before keep alive probes are sent. Defaults to kernel defaults

Parameters
keepAliveTimeoutSecstime interval of no activity, in seconds, before keep alive probes get sent
Returns
this builder object

◆ WithUsername()

MqttClientConnectionConfigBuilder & Aws::Iot::MqttClientConnectionConfigBuilder::WithUsername ( const Crt::String username)
noexcept

Sets username for the connection

Parameters
usernamethe username that will be passed with the MQTT connection
Returns
this builder object

The documentation for this class was generated from the following files: