• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Re: CFReadStreamRead doesn't read data over SSL (HTTPS) server
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re: CFReadStreamRead doesn't read data over SSL (HTTPS) server


  • Subject: Re: Re: CFReadStreamRead doesn't read data over SSL (HTTPS) server
  • From: "Yuvaraj D" <email@hidden>
  • Date: 15 May 2007 08:43:10 -0000
  • Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys

Hi Dominik,

Thanks a ton for the solution.

It worked for me.

Regards,
Yuvaraj


On Tue, 15 May 2007 Dominik Pich wrote :
>As stated earlier:
>
>           // adjust as necessary
>           if( [[self getEndpoint] rangeOfString:@"https"].location !=  NSNotFound ) {
>                NSDictionary *sslSettings = [NSDictionary  dictionaryWithObjectsAndKeys:
>                     (NSString *)kCFStreamSocketSecurityLevelNegotiatedSSL,  kCFStreamSSLLevel,
>                     [NSNumber numberWithBool:YES],  kCFStreamSSLAllowsExpiredCertificates,
>                     [NSNumber numberWithBool:YES], kCFStreamSSLAllowsExpiredRoots,
>                     [NSNumber numberWithBool:YES], kCFStreamSSLAllowsAnyRoot,
>                     [NSNumber numberWithBool:NO],  kCFStreamSSLValidatesCertificateChain,
>                     [NSNull null], kCFStreamSSLPeerName,
>                     nil];
>                               CFReadStreamSetProperty(stream, kCFStreamPropertySSLSettings,  sslSettings);
>           }
>
>Regards, Dominik
>
>On May 14, 2007, at 5:16 PM, Yuvaraj D wrote:
>
>>
>>
>>Hi,
>>
>>I'm writing a XML parser where i'm trying to get the URL with  Authentication from HTTPS server. I'm using CFReadStreamRead to  read the data over the HTTPS stream.
>>
>>But "CFReadStreamRead" fails to read any data and throws up an  error which when logged gives "-9812" which means  "errUnknownRootCert" as seen in the "SecureTransport.h" header file.
>>
>>Here is the code:
>>
>>/********************************************************/
>>
>>UInt8    buffer[kBufferSize];    //    Create the buffer
>>    CFIndex    bytesInBuffer = 0;
>>    CFHTTPMessageRef    messageRef = NULL;
>>    CFReadStreamRef          readStreamRef = NULL;
>>    Boolean bHTTPreturn = false;
>>    Boolean bFlag = false;
>>
>>    CFMutableDataRef data = "" 0);
>>
>>    if ( urlRef == NULL ) return;
>>
>>    // Create the HTTP message
>>    messageRef = CFHTTPMessageCreateRequest( kCFAllocatorDefault,  CFSTR("GET"), urlRef, kCFHTTPVersion1_1 );
>>    if ( messageRef == NULL ) return;
>>
>>    // Create the stream for the request.
>>    readStreamRef    = CFReadStreamCreateForHTTPRequest ( kCFAllocatorDefault, messageRef );
>>    if ( readStreamRef == NULL ) return;
>>
>>    // Authentication
>>    if (username || password)
>>          bHTTPreturn = CFHTTPMessageAddAuthentication(messageRef,  NULL, username, password, kCFHTTPAuthenticationSchemeBasic, false);
>>
>>    // Enable auto-redirect
>>    if ( CFReadStreamSetProperty(readStreamRef,  kCFStreamPropertyHTTPShouldAutoredirect, kCFBooleanTrue) == false )
>>          return;
>>
>>    // Start the HTTP connection
>>    if ( CFReadStreamOpen( readStreamRef ) == false )
>>        return;
>>
>>    // Set the timer
>>    UInt32 startTime = TickCount();
>>
>>    // Loop, reading the data
>>    while (true) {
>>          UInt32 time = TickCount();
>>          if (time < startTime)
>>              startTime = 0;
>>          if ( time > startTime + kTimeout)
>>              return;
>>
>>    CFStreamStatus rStatus = CFReadStreamGetStatus(readStreamRef);
>>          if (rStatus == kCFStreamStatusOpening)
>>              continue;
>>          if ((rStatus == kCFStreamStatusError) || (rStatus ==  kCFStreamStatusClosed) || (rStatus == kCFStreamStatusAtEnd))
>>              break;
>>
>>          if (CFReadStreamHasBytesAvailable (readStreamRef)) {
>>
>>              CFIndex bytesRead = CFReadStreamRead(readStreamRef,  buffer, kBufferSize);
>>              fprintf(stdout, "\n bytesRead = %d\n", (int)bytesRead);
>>              if (bytesRead < 0) {
>>              CFStreamError cfErr;// = (CFStreamError) malloc  (sizeof(CFStreamError));
>>              cfErr = CFReadStreamGetError(readStreamRef);
>>
>>              fprintf(stdout, "\n inside  if (bytesRead < 0)  cfErr.Error = %ld  \n domain = %d \n",cfErr.error, cfErr.domain);
>>//                    CFStreamError error = CFReadStreamGetError (readStreamRef);
>>                    return;
>>              } else {
>>                                        CFDataAppendBytes(data,  buffer, bytesRead);
>>                    startTime = TickCount(); // Reset timer
>>              }
>>          }
>>    }
>>
>>/********************************************************/
>>
>>Has anybody come across this problem?
>>
>>Is there a way to overcome this? I want to know how to read data  communicating with HTTPS servers or servers which are on SSL  (Secure Socket Layer).
>>
>>Thanks & Regards.
>>Yuvaraj
>>
>>
>>
>>
>>
>>
>>  _______________________________________________
>>Do not post admin requests to the list. They will be ignored.
>>Macnetworkprog mailing list      (email@hidden)
>>Help/Unsubscribe/Update your Subscription:
>>
>>This email sent to email@hidden
>



simply holiday
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: AEBS NAT algorithm used
  • Next by Date: Re: Ignoring credentials in shared NSURLCredentialStorage
  • Previous by thread: Re: CFReadStreamRead doesn't read data over SSL (HTTPS) server
  • Next by thread: Cable disconnected event
  • Index(es):
    • Date
    • Thread