how to add ssl support in my cocoa application
how to add ssl support in my cocoa application
- Subject: how to add ssl support in my cocoa application
- From: aashish tiwari <email@hidden>
- Date: Wed, 21 Feb 2007 14:43:26 +0000 (GMT)
Hi list,
I have following method that handles "http://"
requests very well
+ (int) processHTTPRequest:(NSString *) request
withBody: (NSString *) body withResponse:
(NSMutableString *) httpResponse type: (NSString *)
requestType
{
/* Convert the request string to UTF8. */
const char *requestString;
requestString = [request UTF8String]; // request
contains URL of server
/* Convert the body string to UTF8. */
const char *bodyString;
bodyString = [body UTF8String];
/* Create a request */
CFStringRef cfStrRif =
CFStringCreateWithCString(kCFAllocatorDefault,
requestString, kCFStringEncodingUTF8);
CFURLRef cfUrl =
CFURLCreateWithString(kCFAllocatorDefault,cfStrRif,
NULL);
CFHTTPMessageRef httpRequest =
CFHTTPMessageCreateRequest(kCFAllocatorDefault,
(CFStringRef) requestType, cfUrl, kCFHTTPVersion1_1);
CFHTTPMessageSetHeaderFieldValue(httpRequest,
CFSTR("Content-Type"), CFSTR("multipart/form-data;
boundary=Mac08522OU8FPW9IY36"));
CFHTTPMessageSetHeaderFieldValue(httpRequest,
CFSTR("User-Agent"), CFSTR("MC"));
/* CFDataRef does not allocates a new memory area it
works on the buffer allocated */
CFDataRef refData;
/* Attach body to the httpRequest if its a post
request */
if ([requestType isEqualToString:@"POST"])
{
refData = CFDataCreate(kCFAllocatorDefault, (UInt8
*)bodyString, strlen(bodyString));
CFHTTPMessageSetBody(httpRequest,refData);
}
/*
* Open a CF read stream. This establishes the socket
connection and sends the http request,
* and gets the response.
*/
CFReadStreamRef httpReadStream =
CFReadStreamCreateForHTTPRequest(kCFAllocatorDefault,
httpRequest);
/* Now set the proxy for the Stream */
CFDictionaryRef proxyDictionary;
proxyDictionary = [MYServer getProxySettings];
CFReadStreamSetProperty(httpReadStream,
kCFStreamPropertyHTTPProxy, proxyDictionary);
CFReadStreamOpen(httpReadStream);
.....
.......
........
}
Now i need to handle "https://" also....what changes i
need to do in my code so that i can establish SSL
connection with my server.
Please suggest me some tutorial or sample code
available, i dont want much code change...for example
i will prefer to continue using CF functions to
implement SSL support.
Please help me...
Thanks,
Aashish
___________________________________________________________
What kind of emailer are you? Find out today - get a free analysis of your email personality. Take the quiz at the Yahoo! Mail Championship.
http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden