繁体   English   中英

WCF:未提供服务证书。 在ServiceCredentials中指定服务证书

[英]WCF: The service certificate is not provided. Specify a service certificate in ServiceCredentials

我正在尝试创建一个使用MembershipProvider进行身份验证的WCF服务。 因为它是一个内部服务,我目前对应用传输级安全性(HTTPS)不感兴趣,我想(现在)在没有证书的情况下这样做 此外,这将使推出服务变得复杂,我希望稍后这样做。 我已经构建了一个基本配置(即使没有配置MembershipProvider ,但是WCF仍然向我提出以下异常:

未提供服务证书。 在ServiceCredentials中指定服务证书。

这是我的配置:

<system.serviceModel>
  <bindings>
    <ws2007HttpBinding>
      <binding name="Service1WS2007HttpBindingConfig">
        <security mode="Message">
          <transport clientCredentialType="None" />
          <message clientCredentialType="UserName" />
        </security>
      </binding>
    </ws2007HttpBinding>
  </bindings>
  <services>
    <service name="WcfService1.Service1">
      <endpoint address="http://localhost:9800/Service1.svc"
        binding="ws2007HttpBinding"
        bindingConfiguration="Service1WS2007HttpBindingConfig"
        contract="WcfService1.IService1" />
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <behavior name="">
        <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
        <serviceDebug includeExceptionDetailInFaults="false" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <serviceHostingEnvironment multipleSiteBindingsEnabled="false">
    <serviceActivations>
      <add relativeAddress="Service1.svc" service="WcfService1.Service1" />
    </serviceActivations>
  </serviceHostingEnvironment>
</system.serviceModel>

Stacktrace异常:

[InvalidOperationException:未提供服务证书。 在ServiceCredentials中指定服务证书。 ]
System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateServerX509TokenProvider()+ 12382737 System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateLocalSecurityTokenProvider(RecipientServiceModelSecurityTokenRequirement recipientRequirement)+63
System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateSecurityTokenProvider(SecurityTokenRequirement requirements)+48
System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateTlsnegoServerX509TokenProvider(RecipientServiceModelSecurityTokenRequirement recipientRequirement)+191
System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateTlsnegoSecurityTokenAuthenticator(RecipientServiceModelSecurityTokenRequirement recipientRequirement,Boolean requireClientCertificate,SecurityTokenResolver&sctResolver)+683
System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateSecurityTokenAuthenticator(SecurityTokenRequirement tokenRequirement,SecurityTokenResolver&outOfBandTokenResolver)+12383208 System.ServiceModel.Security.SessionRenewSecurityTokenManager.CreateSecurityTokenAuthenticator(SecurityTokenRequirement tokenRequirement,SecurityTokenResolver&outOfBandTokenResolver)+81
System.ServiceModel.Security.SymmetricSecurityProtocolFactory.OnOpen(TimeSpan timeout)+181
System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout)+21
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)+318
System.ServiceModel.Security.SecurityListenerSettingsLifetimeManager.Open(TimeSpan timeout)+94
System.ServiceModel.Channels.SecurityChannelListener`1.OnOpen(TimeSpan timeout)+240
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)+318
System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan超时)+72

[InvalidOperationException:'http:// localhost:9800 / Service1.svc'中的ChannelDispatcher与合同'“IssueAndRenewSession”'无法打开其IChannelListener。
System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)+118
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)+318 System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)+111
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)+318
System.ServiceModel.Security.SecuritySessionSecurityTokenAuthenticator.OnOpen(TimeSpan timeout)+131
System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout)+21
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)+318
System.ServiceModel.Security.CommunicationObjectSecurityTokenAuthenticator.Open(TimeSpan timeout)+20
System.ServiceModel.Security.SecuritySessionServerSettings.OnOpen(TimeSpan timeout)+792
System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout)+21
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)+318
System.ServiceModel.Security.SecurityListenerSettingsLifetimeManager.Open(TimeSpan timeout)+148
System.ServiceModel.Channels.SecurityChannelListener`1.OnOpen(TimeSpan timeout)+240
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)+318
System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan超时)+72

[InvalidOperationException:'http:// localhost:9800 / Service1.svc'中的ChannelDispatcher与合同'“IService1”'无法打开其IChannelListener。
System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)+118
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)+318 System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)+111
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)+318
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath)+206
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)+651

[ServiceActivationException:由于编译期间发生异常,无法激活服务'/Service1.svc'。 异常消息是:'http:// localhost:9800 / Service1.svc'的ChannelDispatcher与合同'“IService1”'无法打开其IChannelListener ..]
System.Runtime.AsyncResult.End(IAsyncResult result)+688590
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result)+190
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context,String routeServiceVirtualPath,Boolean flowContext,Boolean ensureWFService)+234
System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender,EventArgs e)+359
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+ 148 System.Web.HttpApplication.ExecuteStep(IExecutionStep step,Boolean&completedSynchronously)+75

我的配置有什么问题,我该如何解决?

您需要使用证书签署服务。 您可以通过在配置中添加以下内容来执行此操作:

<serviceBehaviors>
    <behavior name="">
        <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
        <serviceDebug includeExceptionDetailInFaults="false" />

        *<serviceCredentials>
            <serviceCertificate findValue="certificatename" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
        </serviceCredentials>*
     </behavior>
</serviceBehaviors>

certificatename是证书的名称。 要创建证书,您可以在此处查看: 创建自签名证书

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM