Sto cercando di utilizzare il framework di sicurezza iOS per comunicare in modo sicuro con il mio server. Ho un file di certificato da cui sono in grado di ottenere un riferimento di chiave pubblica. Questo è quello che sto facendo.SecTrustCreateWithCertificates si blocca su iPad
NSString *certPath = [[NSBundle mainBundle] pathForResource:@"supportwarriors.com" ofType:@"cer"];
SecCertificateRef myCertificate = nil;
NSData *certificateData = [[NSData alloc] initWithContentsOfFile:certPath];
myCertificate = SecCertificateCreateWithData(kCFAllocatorDefault, (CFDataRef)certificateData);
//got certificate ref..Now get public key secKeyRef reference from certificate..
SecPolicyRef myPolicy = SecPolicyCreateBasicX509();
SecTrustRef myTrust;
OSStatus status = SecTrustCreateWithCertificates(myCertificate,myPolicy,&myTrust);
SecTrustResultType trustResult;
if (status == noErr) {
status = SecTrustEvaluate(myTrust, &trustResult);
}
publicKey = SecTrustCopyPublicKey(myTrust);
Sopra il codice funziona perfettamente su iPhone e l'ho provato. Sono in grado di comunicare in modo sicuro con il mio server. Ma quando provo a eseguire la mia app su iPad (in modalità 2x) il codice sopra riportato si arresta. Dopo il debug, ho scoperto che secTrustCreateWithCertificate si arresta in modo anomalo e il registro degli arresti anomali è riportato di seguito. Il certificato che ho usato è lo stesso per iPad e iPhone ... La funzione sopra secCertificateCreateWithData restituisce un riferimento certificato e non è nil ... non è la causa del crash ... Cosa sto sbagliando?
*** -[NSCFType count]: unrecognized selector sent to instance 0x14af24
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFType count]: unrecognized selector sent to instance 0x14af24'
Puoi pubblicare il certificato? – rook