WSS/TLS websocket connection with Swift iOS

Starscream now supports a flag so you can use self-signed certificates: https://github.com/daltoniam/Starscream/blob/bf0146db269249d200bb3bc4185cb5724cfa2ae8/README.md#self-signed-ssl-and-voip

(Edited for posterity; links to the README that was published as of April 2016)


I solved the problem by allowing self-signed certificates Starscream modifying the library. To this must be added the arcivo WebSocket.swift the following code:

if url.scheme == "wss" || url.scheme == "https" {
        inputStream!.setProperty(NSStreamSocketSecurityLevelNegotiatedSSL, forKey: NSStreamSocketSecurityLevelKey)
        outputStream!.setProperty(NSStreamSocketSecurityLevelNegotiatedSSL, forKey: NSStreamSocketSecurityLevelKey)

        /* My code */
        var settings = Dictionary<NSObject, NSObject>()
        settings[kCFStreamSSLValidatesCertificateChain] = NSNumber(bool:false)
        settings[kCFStreamSSLPeerName] = kCFNull

        CFReadStreamSetProperty(self.inputStream, kCFStreamPropertySSLSettings, settings)
        CFWriteStreamSetProperty(self.outputStream, kCFStreamPropertySSLSettings, settings)
        /* End my code*/

    }