我有這樣的代碼:應用傳輸安全:NSURLSession/NSURLConnection的HTTP加載失敗
func loginWithBasicAuth() -> Void {
let usernameText = username.text
let passwordText = password.text
let credentialData = "\(usernameText):\(passwordText)".dataUsingEncoding(NSUTF8StringEncoding)
let base64Credentials = credentialData?.base64EncodedStringWithOptions([])
let headers = ["Authorization": "HTTP Basic \(base64Credentials)"]
Alamofire.request(.GET, "https://api.domainname.com/v0.1/", headers: headers).responseString { aResponse in
if let receivedString = aResponse.result.value {
print(receivedString)
} else {
print("Login failed.")
}
}
}
在它打印控制檯:
NSURLSession/NSURLConnection的HTTP加載失敗 (kCFStreamErrorDomainSSL,-9802) 登錄失敗。
什麼是錯
在您的異常域中嘗試'NSTemporaryExceptionRequiresForwardSecrecy = NO' –
不,沒有任何更改。 –
將此關鍵字'NSIncludesSubdomains'添加到api.domainname.com dictionary.And將其設置爲YES以包含子域名 – Leo