gpt4 book ai didi

ios - 测试 HTTPS 身份验证

转载 作者:行者123 更新时间:2023-11-29 04:05:51 24 4
gpt4 key购买 nike

我正在用 Objective-C 开发一段代码,用于更快地执行 HTTP/HTTPS 请求。该代码将被插入到包含最常见执行操作的库中。我正在寻找一个服务器来测试需要身份验证的 HTTPS 请求。

特别是我看到 iOS 标准库有 NSURLConnection 类。 NSURLConnectionDelegate协议(protocol)有方法connection:didReceiveAuthenticationChallenge:这就是我想在类里面测试的内容。

有什么吗?我在 Google 上进行了搜索,但一无所获。

最佳答案

是的,您是对的,您需要使用 NSURLConnectionDelegate 中的 didReceiveAuthenticationChallenge这是一些示例用法

- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace {
return YES;
}
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
[challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
}

关于ios - 测试 HTTPS 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15246288/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com