iphone - Accept untrusted SSL server certificate with CFStream socket on iOS -
i need open cfstream socket connection server has untrusted ca root. have certificate of server, , can create seccertificateref
structure it. problem how set properties of stream.
i think should set kcfstreampropertysslsettings
property cfdictionary
in turn contains kcfstreamsslcertificates
key. key should hold "a cfarray of seccertificaterefs except first element in array, secidentityref" according docs. can create seccertificateref
server's certificate i'll ship app, how secidentityref
? guess should client identity absolutely don't want client side authentication now. , can't find way how feed cfstream server certificate.
note, don't want add untrusted certificate keychain, neither disable kcfstreamsslvalidatescertificatechain in settings. need accept server authentication if based on own server certificate data loaded disk, , on cfstream.
i not have direct answer question, perhaps few guidelines:
why need use cfstream api , not more intuitive nsurlconnection ?
find in documentation, seams not available mac os x, regarding cfstream api, available ios. think it, , see if can switch nsurlconnection :-)for nsurlconnection, can use nsurlconnectiondelegate methods ssl challenge , validate certificate on own. can check wsdl2objc project, have implemented these features:
- the project: http://code.google.com/p/wsdl2objc/
- some guidelines on how certificate references: http://code.google.com/p/wsdl2objc/wiki/advancedoptions
now questions :-)
don't see how can set custom (untrusted) ca in kcfstreampropertysslsettings. i'm not sure if can done using kcfstreamsslcertificates since meant used setting client-side certificates (thus requirement of having secidentityref on index 0, provides private key).when don't want add certificate keychain, mean manually or programmatically ? guess don't users of app have manually, can use security api import certificate programatically. in case certificate imported in sandboxed keychain available application. (again, not sure if work worths try)
in applications use nsurlconnectiondelegate manually validate untrusted certificates.
regards,
pece
Comments
Post a Comment