diff --git a/Source/WebSocket.swift b/Source/WebSocket.swift index 8b6d02ae..ca1d9a3f 100644 --- a/Source/WebSocket.swift +++ b/Source/WebSocket.swift @@ -388,9 +388,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)