
Untitled
By: a guest on
May 5th, 2012 | syntax:
None | size: 1.49 KB | hits: 15 | expires: Never
Set wcf service credentials in config file for a service with endpoints created in code
var svc = new ServiceHost( typeof (MyService), new Uri(s));
svc.Authorization.PrincipalPermissionMode =
PrincipalPermissionMode.UseWindowsGroups;
svc.AddServiceEndpoint(typeof(IMyService), new WSHttpBinding("MyBinding"), "");
//svc.Credentials.ServiceCertificate.SetCertificate(
// StoreLocation.LocalMachine,
// StoreName.My,
// X509FindType.FindBySubjectName,
// "mycertname"
// );
<system.serviceModel>
<services>
<service name="MyNamespace.MyService" behaviorConfiguration="MyBehavior">
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="MyBinding">
<security mode="Transport">
<transport clientCredentialType="Windows"/>
</security>
<!-- Or for message level security
<security mode="Message">
<message clientCredentialType="Certificate"/>
</security>
-->
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceCredentials>
<serviceCertificate findValue="mycertname"
x509FindType="FindBySubjectName"
storeLocation="LocalMachine"
storeName="My"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>