未经授权的客户端身份验证方案“匿名”和 URI 方案“https”无效;预期的“http”
Posted
技术标签:
【中文标题】未经授权的客户端身份验证方案“匿名”和 URI 方案“https”无效;预期的“http”【英文标题】:unauthorized with client authentication scheme 'Anonymous' & URI scheme 'https' is invalid; expected 'http' 【发布时间】:2017-12-20 09:35:40 【问题描述】:我在使用 Soap 网络服务时收到此错误。我在谷歌搜索时尝试了很多建议,例如:
<security mode="Transport">
<transport clientCredentialType="Certificate" proxyCredentialType="None" realm="weblogic" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
<security mode="TransportCredentialOnly">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
webservice 端点在 https 下,这是我的 c# 代码:
BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
basicHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
basicHttpBinding.Security.Mode = BasicHttpSecurityMode.Transport;
CustomerPortTypeClient client = new CustomerPortTypeClient(basicHttpBinding,
new EndpointAddress("https:......."));
client.ClientCredentials.UserName.UserName = ConfigurationManager.AppSettings["username"].ToString();
client.ClientCredentials.UserName.Password = ConfigurationManager.AppSettings["userpwd"].ToString();
client.ClientCredentials.ClientCertificate.Certificate = new X509Certificate2(ConfigurationManager.AppSettings["servercertfilepath"].ToString());
当我评论 basicHttpBinding.Security.Mode =BasicHttpSecurityMode.Transport;
行时,返回的消息发生了变化,我得到:
详情:提供的URI方案“https”无效;预期的“http”。
参数名称:via。
任何意见或建议将不胜感激。
【问题讨论】:
【参考方案1】:对于那些有同样问题的人。这是通过问题使用的代码:
BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
basicHttpBinding.Security.Mode = BasicHttpSecurityMode.Transport;
basicHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
basicHttpBinding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
basicHttpBinding.Security.Transport.Realm = "weblogic";
basicHttpBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.Certificate;
CustomerPortTypeClient client = new CustomerPortTypeClient(basicHttpBinding,
new EndpointAddress("https:....."));
client.ClientCredentials.ClientCertificate.Certificate = new X509Certificate2(ConfigurationManager.AppSettings["servercertfilepath"].ToString());
client.ClientCredentials.UserName.UserName = ConfigurationManager.AppSettings["username"].ToString();
client.ClientCredentials.UserName.Password = ConfigurationManager.AppSettings["userpwd"].ToString();
【讨论】:
以上是关于未经授权的客户端身份验证方案“匿名”和 URI 方案“https”无效;预期的“http”的主要内容,如果未能解决你的问题,请参考以下文章
HTTP 请求未经客户端身份验证方案“匿名”授权。从服务器收到的身份验证标头是“默认”。
HTTP 请求未经客户端身份验证方案“匿名”授权。从服务器收到的身份验证标头是“基本领域”
WCF-TransportWithMessageCredential HTTP 请求未经授权,客户端身份验证方案“匿名”