Я использую awsIot, чтобы getThingShadow работал ios 12, но получаю сообщение об ошибке ios 13.
pod 'AWSMobileClient'
pod 'AWSIoT', '~> 2.13.0'
func getThingState( thingName: String, completion: @escaping (String, String) -> Void )
{
print("Cognito Identity Id (authenticated): \(String(describing: AWSMobileClient.default().identityId))")
print(AWSMobileClient.default().username)
print(AWSMobileClient.default().credentials())
let IoTData = AWSIoTData.default()
let getThingShadowRequest = AWSIoTDataGetThingShadowRequest()
print(AWSMobileClient.default().credentials())
print(IoTData.configuration)
getThingShadowRequest!.thingName = thingName
IoTData.getThingShadow(getThingShadowRequest!).continueWith { (task) -> AnyObject? in
if let error = task.error {
print("failed: [\(error)]")
}
if (task.error == nil /*&& task.exception == nil*/) {
DispatchQueue.main.async() {
let result = task.result!
do {
// let json = try JSON(data: (result.payload as! NSData?) as! Data)
//completion( thingName, json )
}catch{}
}
}
return nil
}
}
Ошибка ios13 :
Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “data.iot.ap-southeast-1.amazonaws.com” which could put your confidential information at risk." UserInfo={NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, NSErrorPeerCertificateChainKey=(
"<cert(0x7f8a13856800) s: *.iot.ap-southeast-1.amazonaws.com i: Symantec Class 3 ECC 256 bit SSL CA - G2>",
"<cert(0x7f8a13857000) s: Symantec Class 3 ECC 256 bit SSL CA - G2 i: VeriSign Class 3 Public Primary Certification Authority - G5>"
), NSErrorClientCertificateStateKey=0, NSErrorFailingURLKey=https://data.iot.ap-southeast-1.amazonaws.com/things/testThingNoCert/shadow, NSErrorFailingURLStringKey=https://data.iot.ap-southeast-1.amazonaws.com/things/testThingNoCert/shadow, NSUnderlyingError=0x600002c32460 {Error Domain=kCFErrorDomainCFNetwork Code=-1202 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, kCFStreamPropertySSLPeerTrust=<SecTrustRef: 0x60000104aac0>, _kCFNetworkCFStreamSSLErrorOriginalValue=-9807, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9807, kCFStreamPropertySSLPeerCertificates=(
"<cert(0x7f8a13856800) s: *.iot.ap-southeast-1.amazonaws.com i: Symantec Class 3 ECC 256 bit SSL CA - G2>",
"<cert(0x7f8a13857000) s: Symantec Class 3 ECC 256 bit SSL CA - G2 i: VeriSign Class 3 Public Primary Certification Authority - G5>"
)}}, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <9C9FC79B-9072-4C35-B39D-51207517C8B4>.<1>"
), _kCFStreamErrorCodeKey=-9807, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <9C9FC79B-9072-4C35-B39D-51207517C8B4>.<1>, NSURLErrorFailingURLPeerTrustErrorKey=<SecTrustRef: 0x60000104aac0>, NSLocalizedDescription=The certificate for this server is invalid. You might be connecting to a server that is pretending to be “data.iot.ap-southeast-1.amazonaws.com” which could put your confidential information at risk.}]
Ссылка на github: https://github.com/awslabs/aws-sdk-ios-samples/tree/master/IoT-Sample/Swift