找到你要的答案

Q:NTLM authentification loses POST body in iOS app

Q:NTLM认证的iOS应用失去后身体

I'm trying to send requests to web-service with NTLM authentification by standart way:

- (void)connection:(NSURLConnection *)connection
willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
    if ([challenge previousFailureCount] > 0) {
        [[challenge sender] cancelAuthenticationChallenge:challenge];
    } else {
        NSURLCredential *cred = [NSURLCredential
                                 credentialWithUser:username
                                 password:password
                                 persistence:NSURLCredentialPersistenceForSession];

        [[challenge sender] useCredential:cred forAuthenticationChallenge:challenge];
    }
}

GET requests works fine, but there is problem with POST requests. NTLM handshake process loses POST data. It looks like this:

1: iOS  --> Web   POST {body JSON}


2: iOS <--  Web   401 Unauthorized
              WWW-Authenticate: NTLM

3: iOS  --> Web   POST (empty POST request, no body data!)
              Authorization: NTLM <base64-encoded type-1-message>

4: iOS <--  Web   401 Unauthorized
              WWW-Authenticate: NTLM <base64-encoded type-2-message>

5: iOS  --> Web   POST (empty POST request, no body data!)
              Authorization: NTLM <base64-encoded type-3-message>

6: iOS <--  Web   500 Internal Error (it's normal, because body is empty)

There is no problem with Android app, it works as expected. Any ideas?

我试图发送请求到NTLM认证方式通过标准的Web服务:

- (void)connection:(NSURLConnection *)connection
willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
    if ([challenge previousFailureCount] > 0) {
        [[challenge sender] cancelAuthenticationChallenge:challenge];
    } else {
        NSURLCredential *cred = [NSURLCredential
                                 credentialWithUser:username
                                 password:password
                                 persistence:NSURLCredentialPersistenceForSession];

        [[challenge sender] useCredential:cred forAuthenticationChallenge:challenge];
    }
}

获取请求工作良好,但有问题后请求。NTLM握手过程失去后的数据。看起来像这样:

1: iOS  --> Web   POST {body JSON}


2: iOS <--  Web   401 Unauthorized
              WWW-Authenticate: NTLM

3: iOS  --> Web   POST (empty POST request, no body data!)
              Authorization: NTLM <base64-encoded type-1-message>

4: iOS <--  Web   401 Unauthorized
              WWW-Authenticate: NTLM <base64-encoded type-2-message>

5: iOS  --> Web   POST (empty POST request, no body data!)
              Authorization: NTLM <base64-encoded type-3-message>

6: iOS <--  Web   500 Internal Error (it's normal, because body is empty)

Android应用程序没有问题,它的工作预期。有什么想法?

ios  post  ntlm