ios - Swift and SecTrust -


i'm having troubles trying convert code i've found in apple documentation swift code. precise stuff tsl , certificates...

https://developer.apple.com/library/mac/documentation/networkinginternet/conceptual/networkingtopics/articles/overridingsslchainvalidationcorrectly.html

this original code in objective-c

sectrustresulttype secresult = ksectrustresultinvalid; if (sectrustevaluate(trust, &secresult) != errsecsuccess)       return; } 

and attempt...

var secresult:sectrustresulttype = ksectrustresultinvalid // error 1  if (sectrustevaluate(trust, &secresult) != errsecsuccess) { // error 2    return; } 

error 1 is:

'int' not convertible 'sectrustresulttype' 

error 2 is:

 not find overload '!=' accepts supplied arguments 

now, see sectrustresulttype uint32 , ksectrustresultinvalid int... header defined apple suppose should correct :p

typealias sectrustresulttype = uint32 var ksectrustresultinvalid: int { } 

about second error don't know how manage since function sectrustevaluate returns osstatus (that alias uint32) , errsecsuccess osstatus too.

i'm confused. have suggestion make stuff work!?

i ran issue myself , header docs little bit confusing since constants defined ints , sectrustresulttype defined uint32.

but news, solution rather simple init sectrustresulttype ksectrustresultinvalid:

var secresult = sectrustresulttype(ksectrustresultinvalid) if (sectrustevaluate(servertrust, &secresult) != errsecsuccess){        return; } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -