我遇到DefaultCredentials选项和HTTPS问题。如果我使用HTTP协议一切正常 - ntlm授权是可以的,但如果我在Thread.CurrentPrincipal中的webservice端将HTTP更改为HTTPS,我什么都没有(空字符串和IsAuthenticate on false值)。 你有类似的问题吗?
我的Ntlm配置:
internal class NtlmSelfHostConfiguration : HttpSelfHostConfiguration
{
public NtlmSelfHostConfiguration(string baseAddress) : base(baseAddress) { }
public NtlmSelfHostConfiguration(Uri baseAddress) : base(baseAddress) { }
protected override BindingParameterCollection OnConfigureBinding(HttpBinding httpBinding)
{
httpBinding.Security.Mode = HttpBindingSecurityMode.Transport;
httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
return base.OnConfigureBinding(httpBinding);
}
}
创建HttpClient
var handler = new HttpClientHandler() { UseDefaultCredentials = true };
httpClient = new HttpClient(handler);
用户密码基本身份验证工作正常,因此证书没有问题