嗨,我想在Swift中发出Https请求.目前我通过ip地址访问本地服务器.本地服务器有一个SSL证书,通过访问证书想要向服务器发出请求,目前即时这样做.
Alamofire.request(.GET, https://ipaddress//, parameters: [param], headers: headers)
.responseJSON { response in
print(response.request) // original URL request
print(response.response) // URL response
print(response.data) // server data
print(response.result) // result of response serialization
if let JSON = response.result.value {
print("JSON: \(JSON)")
}
}
Run Code Online (Sandbox Code Playgroud)
我已经使用上面的代码来发出请求和plist
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>192.168.2.223:1021(my local ip)</key>
<dict>
Include to allow subdomains-->
<key>NSIncludesSubdomains</key>
<true/>
<!--Include to allow insecure HTTP requests-->
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<!--Include to specify minimum TLS version-->
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>
Run Code Online (Sandbox Code Playgroud)
在plist中我已经给出了这样的但是我仍然得到错误
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, …Run Code Online (Sandbox Code Playgroud)