diff --git a/src/ios/CordovaHttpPlugin.m b/src/ios/CordovaHttpPlugin.m index b4f04b4..5ff6ed6 100644 --- a/src/ios/CordovaHttpPlugin.m +++ b/src/ios/CordovaHttpPlugin.m @@ -404,8 +404,18 @@ } else { CFDictionaryRef identityDict = CFArrayGetValueAtIndex(items, 0); SecIdentityRef identity = (SecIdentityRef)CFDictionaryGetValue(identityDict, kSecImportItemIdentity); + SecTrustRef trust = (SecTrustRef)CFDictionaryGetValue(identityDict, kSecImportItemTrust); - self->x509Credential = [NSURLCredential credentialWithIdentity:identity certificates: nil persistence:NSURLCredentialPersistenceForSession]; + int count = (int)SecTrustGetCertificateCount(trust); + NSMutableArray* trustCertificates = nil; + if (count > 1) { + trustCertificates = [NSMutableArray arrayWithCapacity:SecTrustGetCertificateCount(trust)]; + for (int i=1;ix509Credential = [NSURLCredential credentialWithIdentity:identity certificates: trustCertificates persistence:NSURLCredentialPersistenceForSession]; CFRelease(items); pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];