是不是需要实现ntlm的用户验证?
这个方面有没有相关的代码或者资料,谢谢
这个方面有没有相关的代码或者资料,谢谢
解决方案 »
- 如果我想得到一个float型的数组,下面该怎么写.求教
- 纵向排列ListCtrl绘制表头问题
- 关于ListControl获得行列的问题
- Dialog,View,create到进入等待消息循环之前,最后执行什么事件,处理什么消息?
- 关于FindFirstFile的第一个参数的问题!!!
- 关于字符串数组清空的问题。请指教!
- LoadIcon的问题
- 请问如何才能获得:BSTR *pBuf 这种类型的参数?
- IWebBrowser2 get_Document错误
- 简单问题:如何把char 或者int 转成UCHAR
- 求一算法:怎么随机产生一个最高位为1,低位的倒数第二位为0的32位整数?
- 十万火急。请教大家,关于LSP安装问题
openvpn_snprintf (buf, sizeof(buf), "CONNECT %s:%d HTTP/%s\r\n"
"Host: %s:%d\r\n",
host,
port,
p->options.http_version,
host,
port); msg (D_PROXY, "Send to HTTP proxy: 'CONNECT %s:%d HTTP/%s'", host, port, p->options.http_version); /* send HTTP CONNECT message to proxy */
if (!send_line_crlf (sd, buf))
goto error;
#if 0
/* send User-Agent string if provided */
if (p->options.user_agent)
{
openvpn_snprintf (buf, sizeof(buf), "User-Agent: %s",
p->options.user_agent);
if (!send_line_crlf (sd, buf))
goto error;
} /* auth specified? */
switch (p->auth_method)
{
case HTTP_AUTH_NONE:
break; case HTTP_AUTH_BASIC:
openvpn_snprintf (buf, sizeof(buf), "Proxy-Authorization: Basic %s",
username_password_as_base64 (p, &gc));
msg (D_PROXY, "Attempting Basic Proxy-Authorization");
dmsg (D_SHOW_KEYS, "Send to HTTP proxy: '%s'", buf);
openvpn_sleep (1);
if (!send_line_crlf (sd, buf))
goto error;
break;#if NTLM
case HTTP_AUTH_NTLM:
openvpn_snprintf (buf, sizeof(buf), "Proxy-Authorization: NTLM %s",
ntlm_phase_1 (p, &gc));
msg (D_PROXY, "Attempting NTLM Proxy-Authorization phase 1");
dmsg (D_SHOW_KEYS, "Send to HTTP proxy: '%s'", buf);
openvpn_sleep (1);
if (!send_line_crlf (sd, buf))
goto error;
break;
#endif default:
ASSERT (0);
}
/* send empty CR, LF */
openvpn_sleep (1);
if (!send_crlf (sd))
goto error;
#endif
/* receive reply from proxy */
if (!recv_line (sd, buf, sizeof(buf), p->options.timeout, true, NULL, signal_received))
goto error; /* remove trailing CR, LF */
chomp (buf); msg (D_PROXY, "HTTP proxy returned: '%s'", buf); /* parse return string */
nparms = sscanf (buf, "%*s %d", &status); /* check for a "407 Proxy Authentication Required" response */
if (nparms >= 1 && status == 407)
{
msg (D_PROXY, "Proxy requires authentication"); /* check for NTLM */
if (p->auth_method == HTTP_AUTH_NTLM)
{
#if NTLM
/* look for the phase 2 response */ while (true)
{
if (!recv_line (sd, buf, sizeof(buf), p->options.timeout, true, NULL, signal_received))
goto error;
chomp (buf);
msg (D_PROXY, "HTTP proxy returned: '%s'", buf); openvpn_snprintf (get, sizeof get, "%%*s NTLM %%%ds", (int) sizeof (buf2) - 1);
nparms = sscanf (buf, get, buf2);
buf2[127] = 0; /* we only need the beginning - ensure it's null terminated. */ /* check for "Proxy-Authenticate: NTLM TlRM..." */
if (nparms == 1)
{
/* parse buf2 */
msg (D_PROXY, "auth string: '%s'", buf2);
break;
}
}
/* if we are here then auth string was got */
msg (D_PROXY, "Received NTLM Proxy-Authorization phase 2 response"); /* receive and discard everything else */
while (recv_line (sd, NULL, 0, p->options.timeout, true, NULL, signal_received))
; /* now send the phase 3 reply */ /* format HTTP CONNECT message */
openvpn_snprintf (buf, sizeof(buf), "CONNECT %s:%d HTTP/%s\r\n"
"Host: %s",
host,
port,
p->options.http_version,
host); msg (D_PROXY, "Send to HTTP proxy: 'CONNECT %s:%d HTTP/%s'", host, port, p->options.http_version); /* send HTTP CONNECT message to proxy */
if (!send_line_crlf (sd, buf))
goto error; /* send HOST etc, */
openvpn_sleep (1);
openvpn_snprintf (buf, sizeof(buf), "Host: %s", host);
msg (D_PROXY, "Send to HTTP proxy: '%s'", buf);
if (!send_line_crlf (sd, buf))
goto error; openvpn_snprintf (buf, sizeof(buf), "Proxy-Authorization: NTLM %s",
ntlm_phase_3 (p, buf2, &gc));
msg (D_PROXY, "Attempting NTLM Proxy-Authorization phase 3");
msg (D_PROXY, "Send to HTTP proxy: '%s'", buf);
openvpn_sleep (1);
if (!send_line_crlf (sd, buf))
goto error;
/* ok so far... */
/* send empty CR, LF */
openvpn_sleep (1);
if (!send_crlf (sd))
goto error; /* receive reply from proxy */
if (!recv_line (sd, buf, sizeof(buf), p->options.timeout, true, NULL, signal_received))
goto error; /* remove trailing CR, LF */
chomp (buf); msg (D_PROXY, "HTTP proxy returned: '%s'", buf); /* parse return string */
nparms = sscanf (buf, "%*s %d", &status);
#else
ASSERT (0); /* No NTLM support */
#endif
}
else goto error;
}
/* check return code, success = 200 */
if (nparms < 1 || status != 200)
{
msg (D_LINK_ERRORS, "HTTP proxy returned bad status");
#if 0
/* DEBUGGING -- show a multi-line HTTP error response */
while (true)
{
if (!recv_line (sd, buf, sizeof (buf), p->options.timeout, true, NULL, signal_received))
goto error;
chomp (buf);
msg (D_PROXY, "HTTP proxy returned: '%s'", buf);
}
#endif
goto error;
} /* receive line from proxy and discard */
if (!recv_line (sd, NULL, 0, p->options.timeout, true, NULL, signal_received))
goto error; /*
* Toss out any extraneous chars, but don't throw away the
* start of the OpenVPN data stream (put it in lookahead).
*/
while (recv_line (sd, NULL, 0, 2, false, lookahead, signal_received))
; gc_free (&gc);
return;