The ios project bypasses the certificate to access the https program, and the ios project bypasses the certificate https
For a single webview or request, directly implement NSURLConnectionDelegate in the file h of the request, and add the following two methods in m to implement the following:
C code
-(BOOL) connection :( NSURLConnection *) connection canAuthenticateAgainstProtectionSpace :( NSURLProtectionSpace *) protectionSpace {
Return [protectionSpace. authenticationMethod isinclutostring: NSURLAuthenticationMethodServerTrust];
}
-(Void) connection :( NSURLConnection *) connection didReceiveAuthenticationChallenge :( NSURLAuthenticationChallenge *) challenge {
If ([challenge. protectionSpace. authenticationMethod isinclutostring: NSURLAuthenticationMethodServerTrust])
// If ([trustedHosts containsObject: challenge. protectionSpace. host])
[Challenge. sender useCredential: [NSURLCredential credentialForTrust: challenge. protectionSpace. serverTrust]
ForAuthenticationChallenge: challenge];
[Challenge. sender continueWithoutCredentialForAuthenticationChallenge: challenge];
}
- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace { return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust];}- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) //if ([trustedHosts containsObject:challenge.protectionSpace.host]) [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge]; [challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];}
The above method is uncomfortable because each request must be added.
If three20 is used in the project, you can directly modify "TTRequestLoader. m". The file itself has implemented NSURLConnectionDelegate,
The modification is as follows. You only need to change this location and it is available everywhere.
C code
//////////////////////////////////////// //////////////////////////////////////// ///////////////////
-(Void) connection :( NSURLConnection *) connection
DidReceiveAuthenticationChallenge :( NSURLAuthenticationChallenge *) challenge {
// Modify
If ([challenge. protectionSpace. authenticationMethod isinclutostring: NSURLAuthenticationMethodServerTrust])
[Challenge. sender useCredential: [NSURLCredential credentialForTrust: challenge. protectionSpace. serverTrust] forAuthenticationChallenge: challenge];
[Challenge. sender continueWithoutCredentialForAuthenticationChallenge: challenge];
TTDCONDITIONLOG (TTDFLAG_URLREQUEST, @ "received auth challenge loading % @", _ urlPath );
[_ Queue loader: self didReceiveAuthenticationChallenge: challenge];
}
// Add
-(BOOL) connection :( NSURLConnection *) connection canAuthenticateAgainstProtectionSpace :( NSURLProtectionSpace *) protectionSpace {
Return [protectionSpace. authenticationMethod isinclutostring: NSURLAuthenticationMethodServerTrust];
}
//////////////////////////////////////// //////////////////////////////////////// /// //-(Void) connection :( NSURLConnection *) connectiondidReceiveAuthenticationChallenge :( NSURLAuthenticationChallenge *) challenge {// modify if ([challenge. protectionSpace. authenticationMethod isinclutostring: NSURLAuthenticationMethodServerTrust]) [challenge. sender useCredential: [NSURLCredential credentialForTrust: challenge. protectionSpace. serverTrust] forAuthenticationChallenge: challenge]; [challenge. sender handler: challenge]; TTDCONDITIONLOG (TTDFLAG_URLREQUEST, @ "received auth challenge loading % @", _ urlPath); [_ queue loader: self handler: challenge];} // Add-(BOOL) connection :( NSURLConnection *) connection canAuthenticateAgainstProtectionSpace :( NSURLProtectionSpace *) protectionSpace {return [protectionSpace. authenticationMethod isinclutostring: NSURLAuthenticationMethodServerTrust];}
Why do I ignore certificates for ios https?
[Security and permissions] How does ASIHTTPRequest ignore certificates and request https?
The problem is as follows.
The procedure is as follows:
1. Configure the https website on the server and use the custom certificate.
2. Use the ASIHTTPRequest framework on the ios Client
Www.devdiv.com/..170776
XP disables http webpage access but allows https access. Can this problem be achieved without third-party software?
Built-in firewall custom rules