Skip to content

Commit 915b6cd

Browse files
authored
Exposing functionality to set minimum TLS version (aws#119)
1 parent 4a0a093 commit 915b6cd

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

include/aws/crt/io/TlsOptions.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ namespace Aws
120120
*/
121121
void SetVerifyPeer(bool verifyPeer) noexcept;
122122

123+
/**
124+
* Sets the minimum TLS version allowed.
125+
* @param minimumTlsVersion: The minimum TLS version.
126+
*/
127+
void SetMinimumTlsVersion(aws_tls_versions minimumTlsVersion);
128+
123129
/**
124130
* Overrides the default system trust store.
125131
* @param caPath: Path to directory containing trusted certificates, which will overrides the

include/aws/iot/MqttClient.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ namespace Aws
214214
*/
215215
MqttClientConnectionConfigBuilder &WithTcpKeepAliveMaxProbes(uint16_t maxProbes) noexcept;
216216

217+
MqttClientConnectionConfigBuilder &WithMinimumTlsVersion(aws_tls_versions minimumTlsVersion) noexcept;
218+
217219
/**
218220
* Builds a client configuration object from the set options.
219221
*/

source/io/TlsOptions.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ namespace Aws
128128
aws_tls_ctx_options_set_verify_peer(&m_options, verify_peer);
129129
}
130130

131+
void TlsContextOptions::SetMinimumTlsVersion(aws_tls_versions minimumTlsVersion)
132+
{
133+
AWS_ASSERT(m_isInit);
134+
aws_tls_ctx_options_set_minimum_tls_version(&m_options, minimumTlsVersion);
135+
}
136+
131137
bool TlsContextOptions::OverrideDefaultTrustStore(const char *caPath, const char *caFile) noexcept
132138
{
133139
AWS_ASSERT(m_isInit);

source/iot/MqttClient.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,12 @@ namespace Aws
250250
return *this;
251251
}
252252

253+
MqttClientConnectionConfigBuilder &MqttClientConnectionConfigBuilder::WithMinimumTlsVersion(aws_tls_versions minimumTlsVersion) noexcept
254+
{
255+
m_contextOptions.SetMinimumTlsVersion(minimumTlsVersion);
256+
return *this;
257+
}
258+
253259
MqttClientConnectionConfig MqttClientConnectionConfigBuilder::Build() noexcept
254260
{
255261
if (!m_isGood)

0 commit comments

Comments
 (0)