我对移动应用开发和HTTPS非常陌生,请多多包涵... 我需要您的建议!
我的iPhone应用程序通过使用自签名证书与服务器进行HTTPS通信。
为了解决警告消息显示服务器不受信任的问题,我使用了NSURLConnection委托方法和以下方法:
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])
{
[challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
}
[challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
}
我的第一个问题是:苹果是否会批准这种方法?这是在与使用自签名证书的服务器通信时处理HTTPs请求的允许且合法的方式吗?
当使用上述方法以同意连接到不受信任的服务器时,我的数据是否会通过HTTPs发送,并且是否会被加密?