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 8168413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:30:53+00:00 2026-06-06T20:30:53+00:00

I am very new to iPhone development. I downloaded the iPhoneHTTPServer application from bellow

  • 0

I am very new to iPhone development.

I downloaded the iPhoneHTTPServer application from bellow link.
https://github.com/robbiehanson/CocoaHTTPServer/tree/master/Samples/iPhoneHTTPServer

It works fine for HTTP request.

Now I want to make it as a secure server. (use HTTPS)
for that I have override following two methods in MyHTTPConnection.m

I am sure about changes in this method:

 /**
 * Overrides HTTPConnection's method
 **/
 - (BOOL)isSecureServer
 {
    // Create an HTTPS server (all connections will be secured via SSL/TLS)
    return YES; 
 }

I need to apply changes in bellow method: (Please guide me here.)
PROBLEM : DDKeychain and Cocoa.h is not available for iOS.

 /**
  * Overrides HTTPConnection's method
  * 
  * This method is expected to returns an array appropriate for use in  
  * kCFStreamSSLCertificates SSL Settings.
  * It should be an array of SecCertificateRefs except for the first element in
  * the array, which is a SecIdentityRef.
  **/
  - (NSArray *)sslIdentityAndCertificates
  {
      NSArray *result = [DDKeychain SSLIdentityAndCertificates];
      if([result count] == 0)
      {
        [DDKeychain createNewIdentity];
        return [DDKeychain SSLIdentityAndCertificates];
      }
      return result;
  }
  • 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-06T20:30:55+00:00Added an answer on June 6, 2026 at 8:30 pm

    I have solved issue with following steps:

    1. Export certificate from your Keychain Access(Mac OS X)
      • Open Keychain Access
      • Select Certificate, Right click and select Export…
      • Export Certificate with file format : Personal Information Exchange (.p12)
      • Provide name and password to export file.
        FileName: TestCertificate.p12
        Password: test123 (* try your admin login pass if not worked)

    2. Import TestCertificate.p12 in you XCode project.

    3. Add Security.framework in your project.

    4. Import Security.h file in you code.

      #import <Security/Security.h>

    5. Override and change sslIdentityAndCertificates method as bellow.

        /**
         * Overrides HTTPConnection's method
         * 
         * This method is expected to returns an array appropriate for use in kCFStreamSSLCertificates SSL Settings.
         * It should be an array of SecCertificateRefs except for the first element in the array, which is a SecIdentityRef.
         **/
        - (NSArray *)sslIdentityAndCertificates
        {    
            SecIdentityRef identityRef = NULL;
            SecCertificateRef certificateRef = NULL;
            SecTrustRef trustRef = NULL;
    
            NSString *thePath = [[NSBundle mainBundle] pathForResource:@"TestCertificate" ofType:@"p12"];
            NSData *PKCS12Data = [[NSData alloc] initWithContentsOfFile:thePath]; 
            CFDataRef inPKCS12Data = (CFDataRef)PKCS12Data; 
            CFStringRef password = CFSTR("test123"); 
            const void *keys[] = { kSecImportExportPassphrase }; 
            const void *values[] = { password }; 
            CFDictionaryRef optionsDictionary = CFDictionaryCreate(NULL, keys, values, 1, NULL, NULL); 
            CFArrayRef items = CFArrayCreate(NULL, 0, 0, NULL); 
    
            OSStatus securityError = errSecSuccess;   
            securityError =  SecPKCS12Import(inPKCS12Data, optionsDictionary, &items); 
            if (securityError == 0) { 
                CFDictionaryRef myIdentityAndTrust = CFArrayGetValueAtIndex (items, 0);
                const void *tempIdentity = NULL;
                tempIdentity = CFDictionaryGetValue (myIdentityAndTrust, kSecImportItemIdentity);
                identityRef = (SecIdentityRef)tempIdentity;
                const void *tempTrust = NULL;
                tempTrust = CFDictionaryGetValue (myIdentityAndTrust, kSecImportItemTrust);
                trustRef = (SecTrustRef)tempTrust;
            } else {
                NSLog(@"Failed with error code %d",(int)securityError);
                return nil;
            }
    
            SecIdentityCopyCertificate(identityRef, &certificateRef);
            NSArray *result = [[NSArray alloc] initWithObjects:(id)identityRef, (id)certificateRef, nil];
    
            return result;    
        }
    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am very new to iPhone application development. Am adding the events to iCal from
I'm developing an iPhone application, and I very new on iPhone development. I've created
I'm very new to iPhone development and I'm making an application where I have
I'm very new to iPhone development. I want to create a utility application much
I am very new to iphone application development and am struggling to create a
i am very new to iphone Development and i am asked to use nsxml
I am very new to iPhone. I have developed two version of an application
I'm very new on iPhone development. I wondering where to put some custom initialization
I'm very new to iPhone development so please bear with me. I'm following the
I am new to iPhone app development. I'm very confused with the concepts of

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.