簡體   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