SSL Socket connection iOS -


i trying setup secure connection java run sslserversocket.

i have created own root ca, , have signed certificate java sslserversocket using certificate.

i want add root certificate app certificate signed root certificate work.

so far have secure connection working fine setting read , write stream properties this:

nsdictionary *settings = [[nsdictionary alloc] initwithobjectsandkeys: (id)kcfstreamsocketsecuritylevelnegotiatedssl, kcfstreampropertysocketsecuritylevel, [nsnumber numberwithbool:yes], kcfstreamsslallowsexpiredcertificates, [nsnumber numberwithbool:yes], kcfstreamsslallowsexpiredroots, [nsnumber numberwithbool:no], kcfstreamsslvalidatescertificatechain,nil]; 

i add certificate keychain this:

-(void)addrootcert{ nsstring* rootcertpath = [[nsbundle mainbundle] pathforresource:@"rootca" oftype:@"der"]; nsdata* rootcertdata = [nsdata datawithcontentsoffile:rootcertpath];  osstatus err = noerr; seccertificateref rootcert = seccertificatecreatewithdata(kcfallocatordefault, (__bridge cfdataref)rootcertdata); nsdictionary* dict = [nsdictionary dictionarywithobjectsandkeys:(__bridge_transfer id)ksecclasscertificate, ksecclass, rootcert, ksecvalueref, nil];  err = secitemadd((__bridge cfdictionaryref) dict, null); if (err == noerr) {     nslog(@"sucessfully added root certificate"); }else if (err == errsecduplicateitem){     nslog(@"root certificate exists"); }else{     nslog(@"root certificate add failed"); } } 

this fine want validate certificate chain, app accepts certificates signed ca (or default trusted ones)

how can this?

if set kcfstreamsslvalidatescertificatechain yes, error: cfnetwork sslhandshake failed (-9807) if it's no, doesn't matter signed server certificate, connect regardless (i assume that's right?)

thanks!

technote 2232, "https server trust evaluation", should have answers need. there documentation , several examples of how evaluate server trust.


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

java.util.scanner - How to read and add only numbers to array from a text file -

iphone - Three second countdown in cocos2d -