我正在尝试通过Oauth 1.0授权连接到API端点,但是无法访问。
我尝试过执行邮递员请求,如果我打电话,它可以工作:
hostname.com/blabla/get/items
鉴于我在Oauth 1.0中使用了正确的使用者密钥和机密。
当我在Swift中实现它时,我已经成功地设法用相同的代码连接到另一个端点。
首先,我收到此错误:
An SSL error has occurred and a secure connection to the server cannot be made
我通过将这些行添加到Info.plist并将https://添加到hostname.com/blabla/get/items来解决:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
但是,现在又出现另一个错误:
TIC SSL Trust Error [2:0x281ff64c0]: 3:0
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
Task <7AE2D9F9-5AAE-4E32-B38A-ACAA1032DFE0>.<1> HTTP load failed (error code: -1202 [3:-9813])
Task <7AE2D9F9-5AAE-4E32-B38A-ACAA1032DFE0>.<1> finished with error - code: -1202
requestError[Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “hostname.com” which could put your confidential information at risk." UserInfo={NSURLErrorFailingURLPeerTrustErrorKey=<SecTrustRef: 0x2818ea520>, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9813, NSErrorPeerCertificateChainKey=(
"<cert(0x107174e00) s: Lars i: Lars>"
我找不到此错误的任何解决方案。
最好的问候, 卡斯珀