我正在尝试使用自签名 SSL 设置 WCF 服务。
我可以浏览到 HTTPS,它会显示元数据,我可以创建一个服务引用。
但是它抛出了异常:没有https://wserver:442/service1.svc
可以接受该消息的端点监听。
wserver 是我的服务器的名称,但我没有在任何地方使用它,所以我不知道它从哪里得到它?
我的服务器 Webhost.config (我认为问题可能出在哪里)是:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="Binding1">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehavior" name="AutoSenderWCFService.AutoSenderService">
<endpoint binding="wsHttpBinding" bindingConfiguration="Binding1"
contract="AutoSenderWCFService.IService1" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="AutoSenderWCFService.MyValidator, AutoSenderWCFService"/>
</serviceCredentials>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
或者我在自签名 SSL 上犯了一个错误?
我的客户端只是:
private void button1_Click(object sender, EventArgs e)
{
ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();
client.ClientCredentials.UserName.UserName = "test";
client.ClientCredentials.UserName.Password = "testPassword";
ServiceReference1.Contact[] test = client.GetDrivers();
}
}