From 20285cce972762929a497abf616b1a460b499f32 Mon Sep 17 00:00:00 2001 From: Dipak Kasabwala Date: Mon, 10 Oct 2016 18:14:01 -0400 Subject: [PATCH] [Fixup] crash for SSL Pinning Strange crash --- Source/WebSocket.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/WebSocket.swift b/Source/WebSocket.swift index 8458cf1b..96701d38 100644 --- a/Source/WebSocket.swift +++ b/Source/WebSocket.swift @@ -387,9 +387,9 @@ public class WebSocket : NSObject, StreamDelegate { */ public func stream(_ aStream: Stream, handle eventCode: Stream.Event) { if let sec = security, !certValidated && [.hasBytesAvailable, .hasSpaceAvailable].contains(eventCode) { - let trust = aStream.property(forKey: kCFStreamPropertySSLPeerTrust as Stream.PropertyKey) as AnyObject + let trust = aStream.property(forKey: kCFStreamPropertySSLPeerTrust as Stream.PropertyKey) as! SecTrust let domain = aStream.property(forKey: kCFStreamSSLPeerName as Stream.PropertyKey) as? String - if sec.isValid(trust as! SecTrust, domain: domain) { + if sec.isValid(trust, domain: domain) { certValidated = true } else { let error = errorWithDetail("Invalid SSL certificate", code: 1)