objective c - iOS how to reset NSURLCredential for a given server or make my app forget it ever spoke to that server? -
I'm looking for a way to implement that to talk to my web app with a given server is using .
There is a way for me to "reset" the NSURLCredential ssl for a given server trust and forcing the whole handshaking process to replicate the use of different sets of credentials ? In other words, I want my web app to forget it and talk to this server anytime.
I think the code snippet below is retrieving the credentials I have previously evaluated.
- (zero) customHTTPProtocol: (CustomHTTPProtocol *) Protocol didReceiveAuthenticationChallenge: (NSURLAuthenticationChallenge *) Challenge {NSURLCredential * Credential = Nil; SecTrustRef Trust; NSURLProtectionSpace * protectionSpace = challenge.protectionSpace; If you are referring to trust by ([protectionSpace.authenticationMethod isEqualToString: NSURLAuthenticationMethodServerTrust]) // // We confirm that we have a certificate that this certificate has it, remove the SecTrust object from the challenge, that is / Our trusted anchors are applied for / object, and then evaluate the trust if it is correct, then create a credential to resolve the certification challenge and use //. If anything goes wrong, then challenge the challenge with //, which continues without credentials, due to which the // connections fail. Trust = [security server server]; If (trust == faucet) is not loud (); } Else {// Simply ignore self-signed duties SecTrustResultType results; // This server takes the trust object and checks it against your Chichen SecTrustEvaluate (protectionSpace.serverTrust, & amp; result); // If we want to ignore the invalid server for the certificate, then we accept the server credentials only = [NSURLCredential credentialForTrust: challenge.protectionSpace.serverTrust]; If (? Result == kSecTrustResultProceed || // result == kSecTrustResultConfirm? // deprecated - remove result == kSecTrustResultUnspecified) {[challenge.sender useCredential: Credential forAuthenticationChallenge: challenge]; }} [Solution to Protocol Arrangement Challenge: Credential with Challenge: Credential]; } // ... more ways to solve the challenge}
Tried in ways to get it but vein in all.
But 1 simple trick worked.
To force my web page to re-authenticate, I will add at the end of the request URL.
& amp; R = 1100910192 ** (timestamp) ** .
Therefore, instead of using cached authenticated credentials, it has been re-authenticated.
In other cases just worked by adding # at the end of the request:
[NSMutableURLRequest requestWithURL: [NSURL URLWithString: @ "http: // localhost: 8080 / some Json # "]] I hope this helped.
Comments
Post a Comment