swift 2.3
This commit is contained in:
parent
d8826a9db3
commit
bfa163f3c2
@ -218,8 +218,8 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
|
||||
return (NSURL(), NSURL())
|
||||
}
|
||||
|
||||
let urlPolling = NSURLComponents(string: url.absoluteString)!
|
||||
let urlWebSocket = NSURLComponents(string: url.absoluteString)!
|
||||
let urlPolling = NSURLComponents(string: url.absoluteString!)!
|
||||
let urlWebSocket = NSURLComponents(string: url.absoluteString!)!
|
||||
var queryString = ""
|
||||
|
||||
urlWebSocket.path = socketPath
|
||||
|
||||
@ -70,7 +70,7 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
|
||||
self.options = options
|
||||
self.socketURL = socketURL
|
||||
|
||||
if socketURL.absoluteString.hasPrefix("https://") {
|
||||
if socketURL.absoluteString!.hasPrefix("https://") {
|
||||
self.options.insertIgnore(.Secure(true))
|
||||
}
|
||||
|
||||
|
||||
@ -141,9 +141,9 @@ public class SSLSecurity : NSObject {
|
||||
}
|
||||
var policy: SecPolicyRef
|
||||
if self.validatedDN {
|
||||
policy = SecPolicyCreateSSL(true, domain)
|
||||
policy = SecPolicyCreateSSL(true, domain)!
|
||||
} else {
|
||||
policy = SecPolicyCreateBasicX509()
|
||||
policy = SecPolicyCreateBasicX509()!
|
||||
}
|
||||
SecTrustSetPolicies(trust,policy)
|
||||
if self.usePublicKeys {
|
||||
@ -164,10 +164,10 @@ public class SSLSecurity : NSObject {
|
||||
collect.append(SecCertificateCreateWithData(nil,cert)!)
|
||||
}
|
||||
SecTrustSetAnchorCertificates(trust,collect)
|
||||
var result: SecTrustResultType = 0
|
||||
SecTrustEvaluate(trust,&result)
|
||||
let r = Int(result)
|
||||
if r == kSecTrustResultUnspecified || r == kSecTrustResultProceed {
|
||||
var result = SecTrustResultType(rawValue: 0)
|
||||
SecTrustEvaluate(trust, &result!)
|
||||
let r = Int(result!.rawValue)
|
||||
if r == Int(SecTrustResultType.Unspecified.rawValue) || r == Int(SecTrustResultType.Proceed.rawValue) {
|
||||
var trustedCount = 0
|
||||
for serverCert in serverCerts {
|
||||
for cert in certs {
|
||||
@ -195,7 +195,7 @@ public class SSLSecurity : NSObject {
|
||||
func extractPublicKey(data: NSData) -> SecKeyRef? {
|
||||
guard let cert = SecCertificateCreateWithData(nil, data) else { return nil }
|
||||
|
||||
return extractPublicKeyFromCert(cert, policy: SecPolicyCreateBasicX509())
|
||||
return extractPublicKeyFromCert(cert, policy: SecPolicyCreateBasicX509()!)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -211,7 +211,7 @@ public class SSLSecurity : NSObject {
|
||||
|
||||
guard let trust = possibleTrust else { return nil }
|
||||
|
||||
var result: SecTrustResultType = 0
|
||||
var result = SecTrustResultType(rawValue:0)!
|
||||
SecTrustEvaluate(trust, &result)
|
||||
return SecTrustCopyPublicKey(trust)
|
||||
}
|
||||
@ -246,7 +246,7 @@ public class SSLSecurity : NSObject {
|
||||
let keys = (0..<SecTrustGetCertificateCount(trust)).reduce([SecKeyRef]()) { (keys: [SecKeyRef], index: Int) -> [SecKeyRef] in
|
||||
var keys = keys
|
||||
let cert = SecTrustGetCertificateAtIndex(trust, index)
|
||||
if let key = extractPublicKeyFromCert(cert!, policy: policy) {
|
||||
if let key = extractPublicKeyFromCert(cert!, policy: policy!) {
|
||||
keys.append(key)
|
||||
}
|
||||
|
||||
@ -257,4 +257,4 @@ public class SSLSecurity : NSObject {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,7 +227,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
|
||||
var port = url.port
|
||||
if port == nil {
|
||||
if ["wss", "https"].contains(url.scheme) {
|
||||
if ["wss", "https"].contains(url.scheme!) {
|
||||
port = 443
|
||||
} else {
|
||||
port = 80
|
||||
@ -285,7 +285,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
guard let inStream = inputStream, let outStream = outputStream else { return }
|
||||
inStream.delegate = self
|
||||
outStream.delegate = self
|
||||
if ["wss", "https"].contains(url.scheme) {
|
||||
if ["wss", "https"].contains(url.scheme!) {
|
||||
inStream.setProperty(NSStreamSocketSecurityLevelNegotiatedSSL, forKey: NSStreamSocketSecurityLevelKey)
|
||||
outStream.setProperty(NSStreamSocketSecurityLevelNegotiatedSSL, forKey: NSStreamSocketSecurityLevelKey)
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user