MQTT-Client-Framework icon indicating copy to clipboard operation
MQTT-Client-Framework copied to clipboard

Where can I set ssl/tsl to yes in swift code?

Open SmritiSYadav opened this issue 5 years ago • 1 comments

Short description

Environment

  • Operating system: iOS, tvOS, macOS
  • Software version:
  • Package Manager: Cocoapods, Carthage, Manual
  • MQTTClient version:
  • MQTT Broker used: mosquitto, HiveMQ, vernemq, ...

Link to logs

Create a GIST which is a paste of your logs, and link them here. Please do NOT paste your full logs here, it will make issue very long and hard to read!

Steps to reproduce

Expected behaviour

Actual behaviour

Other information

SmritiSYadav avatar Jan 21 '20 13:01 SmritiSYadav

Follow below setup to enable TLS

        private let session = MQTTSession()!

        let policy = MQTTSSLSecurityPolicy(pinningMode: .none)
        policy?.allowInvalidCertificates = true
        policy?.validatesCertificateChain = false
        policy?.validatesDomainName = false
        
        let transport = MQTTSSLSecurityPolicyTransport()
        transport.host = "192.168.0.1"
        transport.port = 8883
        transport.tls = true
        transport.certificates = nil
        transport.securityPolicy = policy
        
        session.transport = transport
        session.delegate = self

jeeva-sil avatar Feb 25 '20 13:02 jeeva-sil