I'm essentially trying to do what is outlined in this article (Listing 2-6:
Obtaining a Policy Object and Evaluating Trust) in MonoTouch. I have a X509
Certificate and I'm trying to import it and evaluate its trust.

developer.apple.com/library/ios/#documentation/Security/Conceptual/CertKeyTrustProgGuide/iPhone_Tasks/iPhone_Tasks.html#//apple_ref/doc/uid/TP40001358-CH208-DontLinkElementID_9

I can't seem to find the corresponding MonoTouch implementation of OSStatus
or SecTrustEvaluate.

Any help is much appreciated. I also copied and pasted the objective-C code
below.

Thanks much.

Push W.

-- Objective-C Code:

    NSString *thePath = [[NSBundle mainBundle]

                          pathForResource:@"Romeo Montegue" ofType:@"cer"];

    NSData *certData = [[NSData alloc]

                         initWithContentsOfFile:thePath];

    CFDataRef myCertData = (CFDataRef)certData;                 // 1

 

    SecCertificateRef myCert;

    myCert = SecCertificateCreateWithData(NULL, myCertData);    // 2

 

    SecPolicyRef myPolicy = SecPolicyCreateBasicX509();         // 3

 

    SecCertificateRef certArray[1] = { myCert };

    CFArrayRef myCerts = CFArrayCreate(

                                       NULL, (void *)certArray,

                                       1, NULL);

    SecTrustRef myTrust;

    OSStatus status = SecTrustCreateWithCertificates(

                                                    myCerts,

                                                    myPolicy,

                                                    &myTrust);  // 4

 

    SecTrustResultType trustResult;

    if (status == noErr) {

        status = SecTrustEvaluate(myTrust, &trustResult);       // 5

    }

...                                                             // 6

    if (trustResult == kSecTrustResultRecoverableTrustFailure) {

        ...;

    }

...

    if (myPolicy)

        CFRelease(myPolicy);     





--
View this message in context: 
http://monotouch.2284126.n4.nabble.com/Obtaining-a-Policy-Object-and-Evaluating-Trust-in-MonoTouch-tp4656046.html
Sent from the MonoTouch mailing list archive at Nabble.com.
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to