Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8270765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:40:58+00:00 2026-06-08T06:40:58+00:00

I have imported a self-signed X509 certificate into my iPhone by simply emailing the

  • 0

I have imported a self-signed X509 certificate into my iPhone by simply emailing the certificate.pem to it and installing it on the device. Now I would like to verify a particular certificate in my iOS application that must be signed using the aforementioned certificate. Basically, the imported certificate acts as root certificate for a CA.

Does the imported certificate get stored in the Keychain?

How can I programmatically validate another certificate based on the imported one? (the second certificate is only valid if it is signed by the before imported CA certificate)

Does anyone have some experienced with these scenarios?

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T06:40:59+00:00Added an answer on June 8, 2026 at 6:40 am

    1) yes – it sits in your keychain.

    2) you verify it using the trust SecTrustCreateWithCertificates(), SecTrustEvaluate() against either all certificates or just your own.

    3) If you verified it against a wide smattering of certs you can optionally lookup your own cert in the keychain; get the DER; calculate its SHA1 and compare this to a SHA1 which is hardcoded in your code.

    The code is something like below.

    NSMutableArray *serverChain = -- array with what you want to check
    NSMutableArray *trustedCertRefs = <your-hardcoded-certs>;
    
    SecTrustRef noHostTrustRef = NULL;
    OSErr status = SecTrustCreateWithCertificates((__bridge CFArrayRef)serverChain,
                                     SecPolicyCreateSSL(NO, nil), &noHostTrustRef);
    
    if (status != noErr) {
        NSLog(@"SecTrustCreateWithCertificates failed: %hd", status);
        [[challenge sender] cancelAuthenticationChallenge:challenge];
    }
    
    
    status = SecTrustSetAnchorCertificates(noHostTrustRef,
                             (__bridge CFArrayRef)trustedCertRefs);
    if (status != noErr) {
        NSLog(@"SecTrustSetAnchorCertificates failed: %hd", status);
        [[challenge sender] cancelAuthenticationChallenge:challenge];
    }
    
    status = SecTrustEvaluate(noHostTrustRef, &result);
    if (status != noErr) {
        NSLog(@"SecTrustEvaluate failed: %hd", status);
        [[challenge sender] cancelAuthenticationChallenge:challenge];
    }
    CFRelease(noHostTrustRef);
    
    /* From SecTrust.h:
     *
     * SecTrustResultType results have two dimensions.  They specify both whether 
     * evaluation suceeded and whether this is because of a user decision.  
     *
     * In practice the commonly expected result is kSecTrustResultUnspecified,
     * which indicates a positive result that wasn't decided by the user.  
     *
     * The common failure is kSecTrustResultRecoverableTrustFailure, which means a
     * negative result.  kSecTrustResultProceed and kSecTrustResultDeny are the
     * positive and negative result respectively when decided by the user.  User
     *  decisions are persisted through the use of SecTrustCopyExceptions() and
     * SecTrustSetExceptions().  Finally kSecTrustResultFatalTrustFailure is a
     * negative result that should not be circumvented.  In fact only in the case
     * of kSecTrustResultRecoverableTrustFailure should a user ever be asked.
     */
    switch (result) {
        case kSecTrustResultProceed: // 1
        case kSecTrustResultConfirm: // 2
        case kSecTrustResultUnspecified: // 4
            return YES
            break;
        case kSecTrustResultRecoverableTrustFailure:  // 5
        case kSecTrustResultDeny: // 3
        case kSecTrustResultFatalTrustFailure: // 6
        case kSecTrustResultOtherError: // 7
        case kSecTrustResultInvalid: // 0
        default:
            return NO:
            break;
    }
    [[challenge sender] cancelAuthenticationChallenge:challenge];
    

    or if you get a trust chain, say from the network stack which is already verified against the keychain (and thus against your certs) – then you can extract the certs; do a SecCertificateCopyData() on them; and then SHA1 that NSData to compare to your hardcoded sha1 as to ensure it is verified against exactly that one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have imported the data into an database. Patient(pt_id,pt_name,pt_type,pt_loc) Now , I want to
I have imported our SVN repository into Mercurial and now we have entries for
I have a problem with my iPhone program. I have imported a folder into
I have imported a JSF/Facelets project from SVN into Netbeans. Any change which I
I have downloaded CorePlot_0.9 from google and imported in my iPhone project. I want
I have a little module that creates a window (program1). I've imported this into
I have imported the extension CCVideoPlayer to my cocos2d project and I would like
I just recently implemented: https://github.com/gpambrozio/BlockAlertsAnd-ActionSheets I have imported all the necessary files into my
How to list all methods/classes that have been imported into a class. Take an
I have a custom cell with identifyer 'tweetCell' I have imported this into my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.