Skip to content

Commit

Permalink
Add applicationProtocols to TSTLSConfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler committed Nov 24, 2020
1 parent 6f16706 commit 4860150
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Sources/MQTTNIO/TSTLSConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
}

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 4860150

Please sign in to comment.