From 238d3cb3381b44e25e5e1e3c5d2a3c13c4c24db4 Mon Sep 17 00:00:00 2001 From: Erik Date: Tue, 8 Dec 2015 20:15:54 -0500 Subject: [PATCH] add option for selfSigned --- README.md | 1 + Source/SocketEngine.swift | 4 ++++ Source/SocketIOClientOption.swift | 3 +++ 3 files changed, 8 insertions(+) diff --git a/README.md b/README.md index ec44b92..93a2d15 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ case ExtraHeaders([String: String]) // Adds custom headers to the initial reques case HandleQueue(dispatch_queue_t) // The dispatch queue that handlers are run on. Default is the main queue. case VoipEnabled(Bool) // Only use this option if you're using the client with VoIP services. Changes the way the WebSocket is created. Default is false case Secure(Bool) // If the connection should use TLS. Default is false. +case SelfSigned(Bool) // Sets WebSocket.selfSignedSSL (Don't do this, iOS will yell at you) ``` Methods diff --git a/Source/SocketEngine.swift b/Source/SocketEngine.swift index d570d21..94aec48 100644 --- a/Source/SocketEngine.swift +++ b/Source/SocketEngine.swift @@ -67,6 +67,7 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate { private var probing = false private var probeWait = ProbeWaitQueue() private var secure = false + private var selfSigned = false private var session: NSURLSession? private var voipEnabled = false private var waitingForPoll = false @@ -98,6 +99,8 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate { voipEnabled = enable case .Secure(let secure): self.secure = secure + case .SelfSigned(let selfSigned): + self.selfSigned = selfSigned default: continue } @@ -255,6 +258,7 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate { ws?.queue = handleQueue ws?.voipEnabled = voipEnabled ws?.delegate = self + ws?.selfSignedSSL = selfSigned if connect { ws?.connect() diff --git a/Source/SocketIOClientOption.swift b/Source/SocketIOClientOption.swift index 80d24a7..c278336 100644 --- a/Source/SocketIOClientOption.swift +++ b/Source/SocketIOClientOption.swift @@ -44,6 +44,7 @@ public enum SocketIOClientOption: ClientOption { case ReconnectAttempts(Int) case ReconnectWait(Int) case Secure(Bool) + case SelfSigned(Bool) case SessionDelegate(NSURLSessionDelegate) case VoipEnabled(Bool) @@ -95,6 +96,8 @@ public enum SocketIOClientOption: ClientOption { return .VoipEnabled(enable) case ("secure", let secure as Bool): return .Secure(secure) + case ("selfSigned", let selfSigned as Bool): + return .SelfSigned(selfSigned) default: return nil }