本人将wcf服务(使用x509认证)部署在windows7上出现keyset does not exist错误,但是在windows 2003和vista上都是正常,错误信息如下:
Keyset does not exist<br>Server Error in '/DSXLoginService' Application.
Keyset does not existDescription: An unhandled exception occurred during the execution of the current 
web request. Please review the stack trace for more information about the error 
and where it originated in the code. Exception Details: System.Security.Cryptography.CryptographicException: Keyset 
does not exist
Source Error:       An unhandled exception was generated during the execution of the current 
      web request. Information regarding the origin and location of the 
      exception can be identified using the exception stack trace below. Stack Trace: 
[CryptographicException: Keyset does not exist
]
   System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer) +7715070
   System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType keyType, CspParameters parameters, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle) +67
   System.Security.Cryptography.RSACryptoServiceProvider.GetKeyPair() +83
   System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 dwKeySize, CspParameters parameters, Boolean useDefaultKeySize) +226
   System.Security.Cryptography.RSACryptoServiceProvider..ctor(CspParameters parameters) +9
   System.Security.Cryptography.X509Certificates.X509Certificate2.get_PrivateKey() +202
   System.ServiceModel.Security.SecurityUtils.EnsureCertificateCanDoKeyExchange(X509Certificate2 certificate) +69[ArgumentException: The certificate 'CN=ProjectVServer' must have a private key that is capable of key exchange. The process must have access rights for the private key.]
   System.ServiceModel.Security.SecurityUtils.EnsureCertificateCanDoKeyExchange(X509Certificate2 certificate) +11701490
   System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateServerX509TokenProvider() +36
   System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateLocalSecurityTokenProvider(RecipientServiceModelSecurityTokenRequirement recipientRequirement) +63
   System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateSecurityTokenProvider(SecurityTokenRequirement requirement) +54
   System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateTlsnegoServerX509TokenProvider(RecipientServiceModelSecurityTokenRequirement recipientRequirement) +140
   System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateTlsnegoSecurityTokenAuthenticator(RecipientServiceModelSecurityTokenRequirement recipientRequirement, Boolean requireClientCertificate, SecurityTokenResolver& sctResolver) +466
   System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateSecurityTokenAuthenticator(SecurityTokenRequirement tokenRequirement, SecurityTokenResolver& outOfBandTokenResolver) +619
   System.ServiceModel.Security.SessionRenewSecurityTokenManager.CreateSecurityTokenAuthenticator(SecurityTokenRequirement tokenRequirement, SecurityTokenResolver& outOfBandTokenResolver) +85
   System.ServiceModel.Security.SymmetricSecurityProtocolFactory.OnOpen(TimeSpan timeout) +11282375
   System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout) +21
   System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +261
   System.ServiceModel.Security.SecurityProtocolFactory.Open(Boolean actAsInitiator, TimeSpan timeout) +23
   System.ServiceModel.Security.SecurityListenerSettingsLifetimeManager.Open(TimeSpan timeout) +80
   System.ServiceModel.Channels.SecurityChannelListener`1.OnOpen(TimeSpan timeout) +211
   System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +261
   System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) +72
   System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +261
   System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +107
   System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +261
   System.ServiceModel.Security.SecuritySessionSecurityTokenAuthenticator.OnOpen(TimeSpan timeout) +129
   System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout) +21
   System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +261
   System.ServiceModel.Security.CommunicationObjectSecurityTokenAuthenticator.Open(TimeSpan timeout) +20
   System.ServiceModel.Security.SecurityUtils.OpenTokenAuthenticatorIfRequired(SecurityTokenAuthenticator tokenAuthenticator, TimeSpan timeout) +34
   System.ServiceModel.Security.SecuritySessionServerSettings.OnOpen(TimeSpan timeout) +664
   System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout) +21
   System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +261
   System.ServiceModel.Security.SecurityListenerSettingsLifetimeManager.Open(TimeSpan timeout) +133
   System.ServiceModel.Channels.SecurityChannelListener`1.OnOpen(TimeSpan timeout) +211
   System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +261
   System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) +72
   System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +261
   System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +107
   System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +261
   System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +121
   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +479[ServiceActivationException: The service '/DSXLoginService/LoginService.svc' cannot be activated due to an exception during compilation.  The exception message is: The certificate 'CN=ProjectVServer' must have a private key that is capable of key exchange. The process must have access rights for the private key..]
   System.ServiceModel.AsyncResult.End(IAsyncResult result) +11592858
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +194
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext) +176
   System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +275
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET 
Version:2.0.50727.4927 按照网上描述可能是访问权限不够,我进行如下设置还是不行:
FindPrivateKey My LocalMachine -n "CN=ProjectVServer" -a
C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys\75c8c429094a888307626f6ecf0834be
_c6b09530-2639-4ea9-bb76-38ebe4aa4b33cacls.exe "C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys\75c8c429094a888307626f6ecf0834be_c6b09530-2639-4ea9-bb76-38ebe4aa4b33" /E /G "NETWORK SERVICE":R有哪位大侠帮忙看看啊,本人在线等,这个问题已经困扰我好几天了,郁闷啊

解决方案 »

  1.   

    是的,使用vs2008开发的,在windows2003,windows2008和vista上都没问题,就是在windows7上出问题
      

  2.   

    http://www.cryer.co.uk/brian/mswinswdev/ms_vbnet_server_error_in_application.htm
    不知道是不是和这个一样的道理给你参考一下
    This error has been observed when wcf服务(使用x509认证) application has been copied to a server or renamed on the server.
      

  3.   

    楼主,生成证书的时候-n "CN=ProjectVServer" 这个参数是FQDN吗?
      

  4.   

    http://www.cnblogs.com/walkinhill/archive/2007/05/26/565020.html
      

  5.   

    按照下面的步骤可解决 IIS7 Keyset does not exist 的问题, 根源为权限问题
    1:运行 输入 mmc
    2:Console -> file->add/remove snap/in
    3:弹出的界面左边第三项:certificates-> add
    3:弹出的界面选择computer Account 下一步第一个项 ok。
    4:certificates下面找到 Personal certificates 右边 可以找到你创建的证书
    5:最关键的一步:右击证书->All tasks-> manager private keys->在谈出的security中加入 everyone  full control问题解决!!!