使用https certificate swift 4

时间:2018-05-27 05:46:57

标签: swift https

我现在连接到http的网络服务我想连接到https网络服务,我的提供商给我一个文件(),并说这个文件密码是* 如何在ios上使用证书文件,  在android中我使用kso​​ap这样做: android代码:

KeyStore k = KeyMaster.getFromRaw(R.raw.alert, "PKCS12", "123");
((HttpsServiceConnectionSE) httpTransport_net.getServiceConnection()).setSSLSocketFactory(SSL.getSSLSocketFactory(k, "SSL"));

当我在Xcode中删除我的项目并写

let service = VLJBasicHttpBinding_iWCF_Telegram(url:"https://myhttpsUrl")
let test2 =  try? service.HandShake(Input: "test", __error: &ertest)
           print(test2 as Any)

得到此错误

    2018-05-28 14:22:34.847823+0430 test[7221:171962] ATS failed system trust
2018-05-28 14:22:34.848918+0430 test[7221:171962] System Trust failed for [1:0x604000177dc0]
2018-05-28 14:22:34.849947+0430 test[7221:171962] TIC SSL Trust Error [1:0x604000177dc0]: 3:0
2018-05-28 14:22:34.851348+0430 test[7221:171962] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)
2018-05-28 14:22:34.852358+0430 test[7221:171962] Task <D299C5FD-9D33-42DC-88F6-A83B4C1F4DA3>.<1> HTTP load failed (error code: -1200 [3:-9802])
2018-05-28 14:22:34.852974+0430 test[7221:171960] Task <D299C5FD-9D33-42DC-88F6-A83B4C1F4DA3>.<1> finished with error - code: -1200
Optional(nil)

我添加了info.plist

  <key>NSAppTransportSecurity</key>
    <dict>
    <key>NSExceptionDomains</key>
    <dict>
    <key>192.168.30.27</key>
    <dict>
    <key>NSIncludesSubdomains</key>
    <true/>
    <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
    <true/>
    <key>NSTemporaryExceptionMinimumTLSVersion</key>
    <string>TLSv1.1</string>
    </dict>
    </dict>
    </dict>

我想要快速的代码? 我必须在哪里添加我的证书文件?

0 个答案:

没有答案