From 4860150a66ad036158b8af4306d6e195ce410c34 Mon Sep 17 00:00:00 2001 From: Adam Fowler Date: Tue, 24 Nov 2020 15:20:50 +0000 Subject: [PATCH] Add applicationProtocols to TSTLSConfiguration --- Sources/MQTTNIO/TSTLSConfiguration.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Sources/MQTTNIO/TSTLSConfiguration.swift b/Sources/MQTTNIO/TSTLSConfiguration.swift index 83da4fe3..bb63fead 100644 --- a/Sources/MQTTNIO/TSTLSConfiguration.swift +++ b/Sources/MQTTNIO/TSTLSConfiguration.swift @@ -55,6 +55,9 @@ public struct TSTLSConfiguration { /// The identity associated with the leaf certificate. public var clientIdentity: SecIdentity? + /// The application protocols to use in the connection. + public var applicationProtocols: [String] + /// Whether to verify remote certificates. public var certificateVerification: TSCertificateVerification @@ -64,12 +67,14 @@ public struct TSTLSConfiguration { maximumTLSVersion: tls_protocol_version_t? = nil, trustRoots: [SecCertificate]? = nil, clientIdentity: SecIdentity? = nil, + applicationProtocols: [String] = [], certificateVerification: TSCertificateVerification = .fullVerification ) { self.minimumTLSVersion = minimumTLSVersion self.maximumTLSVersion = maximumTLSVersion self.trustRoots = trustRoots self.clientIdentity = clientIdentity + self.applicationProtocols = applicationProtocols self.certificateVerification = certificateVerification } @@ -99,6 +104,10 @@ extension TSTLSConfiguration { sec_protocol_options_set_local_identity(options.securityProtocolOptions, secClientIdentity) } + applicationProtocols.forEach { + sec_protocol_options_add_tls_application_protocol(options.securityProtocolOptions, $0) + } + if certificateVerification != .fullVerification || trustRoots != nil { // add verify block to control certificate verification sec_protocol_options_set_verify_block(