mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Update Meshtastic/Helpers/Mqtt/MqttClientProxyManager.swift
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
dc00d8d118
commit
5e6486b8d4
1 changed files with 17 additions and 1 deletions
|
|
@ -131,8 +131,24 @@ extension MqttClientProxyManager: CocoaMQTTDelegate {
|
|||
}
|
||||
}
|
||||
func mqtt(_ mqtt: CocoaMQTT, didReceive trust: SecTrust, completionHandler: @escaping (Bool) -> Void) {
|
||||
completionHandler(true)
|
||||
var isValid = false
|
||||
#if canImport(Security)
|
||||
if #available(macOS 10.15, iOS 13.0, *) {
|
||||
isValid = SecTrustEvaluateWithError(trust, nil)
|
||||
} else {
|
||||
var result: SecTrustResultType = .invalid
|
||||
let status = SecTrustEvaluate(trust, &result)
|
||||
isValid = (status == errSecSuccess) && (result == .unspecified || result == .proceed)
|
||||
}
|
||||
#endif
|
||||
if isValid {
|
||||
Logger.mqtt.info("📲 [MQTT Client Proxy] TLS validation succeeded.")
|
||||
completionHandler(true)
|
||||
} else {
|
||||
Logger.mqtt.error("📲 [MQTT Client Proxy] TLS validation failed.")
|
||||
completionHandler(false)
|
||||
}
|
||||
}
|
||||
func mqttDidDisconnect(_ mqtt: CocoaMQTT, withError err: Error?) {
|
||||
Logger.mqtt.debug("📲 [MQTT Client Proxy] disconnected: \(err?.localizedDescription ?? "", privacy: .public)")
|
||||
if let error = err {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue