我使用这段代码连接到第三方服务器。
using (HttpClientHandler httpClientHandler = new HttpClientHandler())
{
httpClientHandler.AllowAutoRedirect = false;
httpClientHandler.Credentials = new NetworkCredential(login, password);
using (HttpClient authClient = new HttpClient(httpClientHandler))
{
response = await authClient.GetAsync(authenticationUrl).ConfigureAwait(false);
... response processing here
}
}第三方服务器是一种设备,他们最近打开了NTLM。从打开NTLM开始,我的请求现在得到一个HTTP 500错误,如下所示:
键入指定的异常报告消息NTLM。降级为Basic (和/或SSL),但不支持降级。说明服务器遇到一个内部错误,无法满足此请求。异常java.lang.UnsupportedOperationException:指定NTLM。降级为Basic (和/或SSL),但不支持降级。net.sourceforge.spnego.SpnegoProvider.negotiate(SpnegoProvider.java:146) net.sourceforge.spnego.SpnegoAuthenticator.authenticate(SpnegoAuthenticator.java:271) net.sourceforge.spnego.SpnegoHttpFilter.doFilter(SpnegoHttpFilter.java:229)
我假设httpclient看到服务器现在支持NTLM并尝试执行NTLM。有什么方法可以告诉我的httpclient甚至不用去使用NTLM吗?
发布于 2018-02-15 09:58:51
要禁用NTLM,请尝试如下:
var modules = AuthenticationManager.RegisteredModules;
while (modules.MoveNext())
{
var module = (IAuthenticationModule) modules.Current;
if (module.AuthenticationType == "NTLM")
{
AuthenticationManager.Unregister(module);
break;
}
}https://stackoverflow.com/questions/46448386
复制相似问题