[英]WCF: The service certificate is not provided. Specify a service certificate in ServiceCredentials
I'm trying to create a WCF service that uses the MembershipProvider
for authentication. 我正在尝试创建一个使用
MembershipProvider
进行身份验证的WCF服务。 Because it is an internal service I'm currently not interested in applying transport level security (HTTPS) and I want to (for now) do this without a certificate . 因为它是一个内部服务,我目前对应用传输级安全性(HTTPS)不感兴趣,我想(现在)在没有证书的情况下这样做 。 Besides, this will complicate rolling out the service and I wish to do this at a later point in time.
此外,这将使推出服务变得复杂,我希望稍后这样做。 I've built a basic configuration (even without configuring the
MembershipProvider
, but WCF keeps throwing me the following exception: 我已经构建了一个基本配置(即使没有配置
MembershipProvider
,但是WCF仍然向我提出以下异常:
The service certificate is not provided.
未提供服务证书。 Specify a service certificate in ServiceCredentials.
在ServiceCredentials中指定服务证书。
Here's my configuration: 这是我的配置:
<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 of the exception: Stacktrace异常:
[InvalidOperationException: The service certificate is not provided.
[InvalidOperationException:未提供服务证书。 Specify a service certificate in ServiceCredentials.
在ServiceCredentials中指定服务证书。 ]
]
System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateServerX509TokenProvider() +12382737 System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateLocalSecurityTokenProvider(RecipientServiceModelSecurityTokenRequirement recipientRequirement) +63System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateServerX509TokenProvider()+ 12382737 System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateLocalSecurityTokenProvider(RecipientServiceModelSecurityTokenRequirement recipientRequirement)+63
System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateSecurityTokenProvider(SecurityTokenRequirement requirement) +48System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateSecurityTokenProvider(SecurityTokenRequirement requirements)+48
System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateTlsnegoServerX509TokenProvider(RecipientServiceModelSecurityTokenRequirement recipientRequirement) +191System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateTlsnegoServerX509TokenProvider(RecipientServiceModelSecurityTokenRequirement recipientRequirement)+191
System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateTlsnegoSecurityTokenAuthenticator(RecipientServiceModelSecurityTokenRequirement recipientRequirement, Boolean requireClientCertificate, SecurityTokenResolver& sctResolver) +683System.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) +81System.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) +181System.ServiceModel.Security.SymmetricSecurityProtocolFactory.OnOpen(TimeSpan timeout)+181
System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout) +21System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout)+21
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +318System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)+318
System.ServiceModel.Security.SecurityListenerSettingsLifetimeManager.Open(TimeSpan timeout) +94System.ServiceModel.Security.SecurityListenerSettingsLifetimeManager.Open(TimeSpan timeout)+94
System.ServiceModel.Channels.SecurityChannelListener`1.OnOpen(TimeSpan timeout) +240System.ServiceModel.Channels.SecurityChannelListener`1.OnOpen(TimeSpan timeout)+240
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +318System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)+318
System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) +72System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan超时)+72
[InvalidOperationException: The ChannelDispatcher at 'http://localhost:9800/Service1.svc' with contract(s) '"IssueAndRenewSession"' is unable to open its IChannelListener.]
[InvalidOperationException:'http:// localhost:9800 / Service1.svc'中的ChannelDispatcher与合同'“IssueAndRenewSession”'无法打开其IChannelListener。
System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) +118System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)+118
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +318 System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +111System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)+318 System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)+111
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +318System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)+318
System.ServiceModel.Security.SecuritySessionSecurityTokenAuthenticator.OnOpen(TimeSpan timeout) +131System.ServiceModel.Security.SecuritySessionSecurityTokenAuthenticator.OnOpen(TimeSpan timeout)+131
System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout) +21System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout)+21
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +318System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)+318
System.ServiceModel.Security.CommunicationObjectSecurityTokenAuthenticator.Open(TimeSpan timeout) +20System.ServiceModel.Security.CommunicationObjectSecurityTokenAuthenticator.Open(TimeSpan timeout)+20
System.ServiceModel.Security.SecuritySessionServerSettings.OnOpen(TimeSpan timeout) +792System.ServiceModel.Security.SecuritySessionServerSettings.OnOpen(TimeSpan timeout)+792
System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout) +21System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout)+21
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +318System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)+318
System.ServiceModel.Security.SecurityListenerSettingsLifetimeManager.Open(TimeSpan timeout) +148System.ServiceModel.Security.SecurityListenerSettingsLifetimeManager.Open(TimeSpan timeout)+148
System.ServiceModel.Channels.SecurityChannelListener`1.OnOpen(TimeSpan timeout) +240System.ServiceModel.Channels.SecurityChannelListener`1.OnOpen(TimeSpan timeout)+240
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +318System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)+318
System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) +72System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan超时)+72
[InvalidOperationException: The ChannelDispatcher at 'http://localhost:9800/Service1.svc' with contract(s) '"IService1"' is unable to open its IChannelListener.]
[InvalidOperationException:'http:// localhost:9800 / Service1.svc'中的ChannelDispatcher与合同'“IService1”'无法打开其IChannelListener。
System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) +118System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)+118
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +318 System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +111System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)+318 System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)+111
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +318System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)+318
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +206System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath)+206
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +651System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)+651
[ServiceActivationException: The service '/Service1.svc' cannot be activated due to an exception during compilation.
[ServiceActivationException:由于编译期间发生异常,无法激活服务'/Service1.svc'。 The exception message is: The ChannelDispatcher at 'http://localhost:9800/Service1.svc' with contract(s) '"IService1"' is unable to open its IChannelListener..]
异常消息是:'http:// localhost:9800 / Service1.svc'的ChannelDispatcher与合同'“IService1”'无法打开其IChannelListener ..]
System.Runtime.AsyncResult.End(IAsyncResult result) +688590System.Runtime.AsyncResult.End(IAsyncResult result)+688590
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +190System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result)+190
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, String routeServiceVirtualPath, Boolean flowContext, Boolean ensureWFService) +234System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context,String routeServiceVirtualPath,Boolean flowContext,Boolean ensureWFService)+234
System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +359System.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) +75System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+ 148 System.Web.HttpApplication.ExecuteStep(IExecutionStep step,Boolean&completedSynchronously)+75
What is wrong with my configuration and how can I solve this? 我的配置有什么问题,我该如何解决?
You need to sign the service with a certificate. 您需要使用证书签署服务。 You can do this by adding the following to the configuration:
您可以通过在配置中添加以下内容来执行此操作:
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
*<serviceCredentials>
<serviceCertificate findValue="certificatename" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
</serviceCredentials>*
</behavior>
</serviceBehaviors>
Where certificatename is the name of your certificate. certificatename是证书的名称。 To create a certificate you can look here: Create a self signed certificate
要创建证书,您可以在此处查看: 创建自签名证书
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.