novastone-media / MQTT-Client-Framework

iOS, macOS, tvOS native ObjectiveC MQTT Client Framework
Other
1.84k stars 463 forks source link

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

Open SmritiSYadav opened 4 years ago

SmritiSYadav commented 4 years ago

Short description

Environment

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

jeeva-sil commented 4 years ago

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