Skip to content

Commit

Permalink
[Fixup] crash for SSL Pinning Strange crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Dipak Kasabwala committed Oct 10, 2016
1 parent d831901 commit 20285cc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Source/WebSocket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 20285cc

Please sign in to comment.