Skip to content

Commit

Permalink
Add port 443 check for secure transport to avoid backward compat issue
Browse files Browse the repository at this point in the history
  • Loading branch information
alfianlosari committed Jul 10, 2023
1 parent 21d9e6d commit a3166b0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CourierCore/Models/ConnectOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ public struct ConnectOptions: Equatable {
self.alpn = alpn
self.scheme = scheme
}

public var shouldUseSecureTransportLayer: Bool {
scheme == "ssl" || scheme == "tls" || port == 443
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class MQTTClientFrameworkConnection: NSObject, IMQTTConnection {
let port = Int(connectOptions.port)
var securityPolicy: MQTTSSLSecurityPolicy?

if connectOptions.scheme == "ssl" || connectOptions.scheme == "tls" {
if connectOptions.shouldUseSecureTransportLayer {
securityPolicy = MQTTSSLSecurityPolicy()
securityPolicy?.allowInvalidCertificates = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class MQTTClientFrameworkSessionManager: NSObject, IMQTTClientFrameworkSessionMa
printDebug("MQTT - COURIER: Client Session Manager connect to: \(host)")
self.connectOptions = connectOptions
let shouldReconnect = self.session != nil
let isTls = connectOptions.scheme == "ssl" || connectOptions.scheme == "tls"
let isTls = connectOptions.shouldUseSecureTransportLayer

if (self.session == nil || host != self.host) ||
port != self.port ?? 0 ||
Expand Down

0 comments on commit a3166b0

Please sign in to comment.