2
我有一个远程WCF服务,我通过WsHttpBinding的连接。如果我使用空的服务构造函数,这意味着它将从app.config中获取所有配置,一切正常(我的意思是MyService s = new MyService())。 现在我想以编程方式配置wcf。这很简单,直到我到达认证问题,这是很难做到这一点。这里是我使用的app.config,你可以在那里看到我的安全配置。配置WCF服务编程
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="SecuredEndPoint" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="true" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://MyWcfService.svc"
binding="wsHttpBinding" bindingConfiguration="SecuredEndPoint"
contract="ServiceReference1.IMyService" name="SecuredEndPoint">
<identity>
<certificate encodedValue="*******************************************************************" />
</identity>
</endpoint>
</client>
</system.serviceModel>
但在那里我可以看到在身份代码证书encodedValue问题,这真的是我的大问题。 – Wasim 2012-01-11 19:33:08
试试这个'EndpointIdentity身份= EndpointIdentity.CreateX509CertificateIdentity(新System.Security.Cryptography.X509Certificates.X509Certificate2(Encoding.UTF8.GetBytes( “您的证书”));',把给这个身份'EndpointAddress'构造你都会有。要修改安全模式 – 2012-01-12 04:39:08
我:客户端无法确定基于目标地址http身份服务主体名称://MyService.svc/securedendpoint”的SspiNegotiation/Kerberos的宗旨目标地址的标识必须是UPN我的代码设置识别码是:var encodedValue = “**** Y”; EndpointIdentity identity = EndpointIdentity.CreateX509CertificateIdentity(new System。 Security.Cryptography.X509Certificates.X509Certificate2(Encoding.UTF8.GetBytes(encodedValue))); – Wasim 2012-01-15 07:48:17