0

我从 Iphone 应用程序登录网站时遇到问题。它是一个 https,因此是一个 SSL 安全站点。不幸的是,当我尝试登录时收到一条错误消息。而且我不知道如何解决这个错误。

这里的错误信息:

2012-08-20 13:38:56.490 Login_2[330:f803] IN GETFILELIST: (null)
2012-08-20 13:38:56.903 Login_2[330:f803] ERROR: (null)
2012-08-20 13:38:56.914 Login_2[330:f803] ERROR!: 
Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo=0x6ab9ac0 {NSErrorFailingURLStringKey=https://www.remote.sokratherm.de:80/?content=tableau&tableau=1, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSErrorFailingURLKey=https://www.remote.sokratherm.de:80/?content=tableau&tableau=1, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSUnderlyingError=0x6abea00 "An SSL error has occurred and a secure connection to the server cannot be made."}

这里的代码:

NSString *apiPath = [NSString stringWithFormat:@"https://%@:%@/", hostServer, hostPort];

httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:apiPath]];
[httpClient setAuthorizationHeaderWithUsername:hostUser password:hostPass];

NSMutableURLRequest *request = [httpClient requestWithMethod:@"POST" path:@"index.php" parameters:nil];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];

如果您需要更多信息,请询问。我很高兴有任何帮助。

问候。

4

2 回答 2

2

服务器www.remote.sokratherm.de似乎没有在端口 80 上使用 SSL 运行。您是要指定该端口吗?如果没有,请:80从您的请求 URL 中删除。

于 2012-08-20T11:58:31.900 回答
1

你应该检查这两种方法:

[operation setAuthenticationAgainstProtectionSpaceBlock:^BOOL(NSURLConnection *connection, NSURLProtectionSpace *protectionSpace)
{
    //return YES or NO according to information received in 
    //objects *connection* and *protectionSpace*
}];

和这个:

[operation setAuthenticationAgainstProtectionSpaceBlock:^BOOL(NSURLConnection *connection, NSURLProtectionSpace *protectionSpace)
{
    **if ([challenge.protectionSpace.host isEqualToString:@"YOURHOST"])**
    {
        [[challenge sender] useCredential:[NSURLCredential credentialWithUser:@"YOURUSER" password:@"YOURPASSWORD" persistence:NSURLCredentialPersistenceNone] forAuthenticationChallenge:challenge];
}
}];
于 2012-08-20T11:56:22.923 回答