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

  • Home
  • SEARCH
  • 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 5996261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:04:41+00:00 2026-05-23T00:04:41+00:00

I am writing an application that uses NSStream’s SSL functions on the iphone. I

  • 0

I am writing an application that uses NSStream’s SSL functions on the iphone. I know that SSL is working because I can directly connect servers using SSL.
I have encountered a problem where protocols that use starttls require me to communicate on the socket with unsecured, send the starttls command and then reuse the same socket for SSL. As far as i know nsstream connections cannot be reused and i can’t start SSL on them after i have opened the connection.

I thought about creating my own socket, communicating on it manually and then setting up an NSstream using the existing socket and start SSL that way. However, it appears the communicating on the socket places it in a state where i cant start SSL on it. Any attempt to use the socket for nsstream results in an error.

Any thoughts?

  • 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-05-23T00:04:42+00:00Added an answer on May 23, 2026 at 12:04 am

    This is the correct way to do this. while doing this (setting the property after socket connection) is undocumented, this is code directly from my Monal xmpp client and apple has never given me any problems in the app store.

     NSInputStream *iStream;
    NSOutputStream *oStream;
    
    
    CFStreamCreatePairWithSocketToHost(NULL, (CFStringRef)server, port, &iStream, &oStream);
    
    
    [iStream open];
        [oStream open];
    

    Once the connection has been opened and you get NSStreamEventOpenCompleted and the startTLS command has been sent to the host from the client:

    NSDictionary *settings = [ [NSDictionary alloc ] 
                                      initWithObjectsAndKeys:
                                      [NSNumber numberWithBool:YES], @"kCFStreamSSLAllowsExpiredCertificates",
                                      [NSNumber numberWithBool:YES], @"kCFStreamSSLAllowsExpiredRoots",
                                      [NSNumber numberWithBool:YES], @"kCFStreamSSLAllowsAnyRoot",
                                      [NSNumber numberWithBool:NO], @"kCFStreamSSLValidatesCertificateChain",
                                      [NSNull null],@"kCFStreamSSLPeerName",
                                      @"kCFStreamSocketSecurityLevelNegotiatedSSL", 
                                      @"kCFStreamSSLLevel",
                                      nil ];
            CFReadStreamSetProperty((CFReadStreamRef)iStream, 
                                    @"kCFStreamPropertySSLSettings", (CFTypeRef)settings);
            CFWriteStreamSetProperty((CFWriteStreamRef)oStream, 
                                     @"kCFStreamPropertySSLSettings", (CFTypeRef)settings);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently writing an iPhone application that uses a UITabBarController with more than 5
I'm writing an application that uses renaming rules to rename a list of files
I'm writing an application in PHP that uses a LOT of global variables that
I'm writing a simple OpenGL application that uses GLUT . I don't want to
I am writing an application that uses Equinox as my OSGi framework. I am
I'm writing an application that uses UIImagePickerController. I'd like to give users choice of
I'm currently writing an application that uses Pygments to perform syntax highlighting. The problem
I am writing an application that uses 3rd party libraries to instantiate and make
I'm writing an application that uses Dijkstra algorithm to find minimal paths in the
I am writing an application that uses Synchronous NSURLConnection(s) and am finding that 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.