Under iOS, the HTTPS link needs to be turned on, but if proxy access is used, it will be returned by default with a certificate validation error and no normal access
Usually in the case of domestic visits to foreign Facebook
This is because
HTTPS access, the certificate will be verified once, if the use of agents, the certificate will be considered risky, it will reject the connection
That is, to avoid a man-in-the-middle attack.
Here you can consider the first use of nsurlconnection to create an HTTPS connection, so that the connection to the destination address at the time of authentication ignore the certificate, you can ensure that the subsequent connection and no certificate validation issues
nsstring* strURL = [NSString stringWithFormat: @https://graph.facebook.com/me];nsurlrequest* Requrl =[Nsurlrequest Requestwithurl:[nsurl Urlwithstring:strurl]; Nsurlconnection* conn = [nsurlconnection Connectionwithrequest:requrlDelegate: Self]; [Conn start]; - (void) Connection: (Nsurlconnection *) connection didfailwitherror: (Nserror *) error{NSLog (@"connection Didfailwitherror Result:%@", error);}-(BOOL) Connectionshouldusecredentialstorage: (Nsurlconnection *) connection{returnNO;}- (void) Connection: (Nsurlconnection *) connection Willsendrequestforauthenticationchallenge: ( Nsurlauthenticationchallenge *) challenge{//the first pass is validated, then the validation is canceled if([challenge previousfailurecount] = =0) {nsurlcredential*credential =[Nsurlcredential CredentialForTrust:challenge.protectionSpace.serverTrust];
[[Challenge Sender] usecredential:credential Forauthenticationchallenge:challenge]; } Else{[[Challenge Sender] cancelauthenticationchallenge:challenge]; }}//Deprecated authentication delegates.-(BOOL) connection: (Nsurlconnection *) connection canauthenticateagainstprotectionspace: (Nsurlprotectionspace *) protectionspace{return[Protectionspace.authenticationmethod isequaltostring:nsurlauthenticationmethodservertrust];}- (void) Connection: (Nsurlconnection *) connection Didreceiveauthenticationchallenge: (Nsurlauthenticationchallenge *) challenge{//the first pass is validated, then the validation is canceled if([challenge previousfailurecount] = =0) {nsurlcredential*credential =[Nsurlcredential CredentialForTrust:challenge.protectionSpace.serverTrust];
[[Challenge Sender] usecredential:credential Forauthenticationchallenge:challenge]; } Else{[[Challenge Sender] cancelauthenticationchallenge:challenge]; }}- (void) Connection: (Nsurlconnection *) connection Didcancelauthenticationchallenge: (Nsurlauthenticationchallenge *) challenge{}- (void) Connection: (Nsurlconnection *) connection didreceiveresponse: (Nsurlresponse *) response{//do the things you need to do}
But this is best to see the latest SDK support is not supported.
HTTPS proxy Access certificate issues under iOS