相关疑难解决方法(0)

Swift:如何使用服务器SSL证书进行Https请求

嗨,我想在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)

ssl https ios swift

1
推荐指数
1
解决办法
3163
查看次数

标签 统计

https ×1

ios ×1

ssl ×1

swift ×1