Fix #225: HTTP re-authentication with NTLM fails
authorStefan Becker <chemobejk@gmail.com>
Thu, 5 Dec 2013 20:34:46 +0000 (5 22:34 +0200)
committerStefan Becker <chemobejk@gmail.com>
Thu, 5 Dec 2013 20:48:42 +0000 (5 22:48 +0200)
The built-in NTLM implementation didn't support re-authentication. With
HTTP 1.1 keep-alive support of the new HTTP stack this has become
necessary now.

(cherry picked from commit 3f3dcfc3caecacec333e73efb9c850df4fec7c70)

src/core/sip-sec-ntlm.c

index af03e00..31ae4f0 100644 (file)
@@ -1752,6 +1752,17 @@ sip_sec_init_sec_context__ntlm(SipSecContext context,
 
        SIPE_DEBUG_INFO_NOFORMAT("sip_sec_init_sec_context__ntlm: in use");
 
+       /*
+        * If authentication was already completed, then this mean a new
+        * authentication handshake has started on the existing connection.
+        * We must throw away the old context, because we need a new one.
+        */
+       if (context->flags & SIP_SEC_FLAG_COMMON_READY) {
+               SIPE_DEBUG_INFO_NOFORMAT("sip_sec_init_sec_context__ntlm: dropping old context");
+               context->flags &= ~SIP_SEC_FLAG_COMMON_READY;
+               context->flags |=  SIP_SEC_FLAG_NTLM_INITIAL;
+       }
+
        if (context->flags & SIP_SEC_FLAG_NTLM_INITIAL) {
                context->flags &= ~SIP_SEC_FLAG_NTLM_INITIAL;