你好,
我在互联网场景中写作服务。我必须实现消息加密。我得到了一切,但当我从IIS浏览此服务时,我遇到了异常。
'/ MyTestService'中的服务器错误 应用
密钥集不存在
描述:未处理的异常 在执行期间发生 当前的网络请求。请查看 堆栈跟踪以获取更多信息 错误及其来源 代码。
异常详细信息: System.Security.Cryptography.CryptographicException: 键集没有 存在................................................. ..............
............................................... .....................
好像是证书问题。有人可以解释如何处理证书的问题,请详细说明。试想我是证书的新手。
<system.serviceModel>
<services>
<service name="Test.MyService" behaviorConfiguration="MyServiceBehavior">
<!-- Service Endpoints -->
<endpoint address="MyTestService" binding="wsHttpBinding" bindingConfiguration="WebserviceHttpBinding" contract="Test.IMyService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="WebserviceHttpBinding">
<security mode="Message">
<message clientCredentialType="UserName" negotiateServiceCredential="false"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Test.CredentialValidator, Test"/>
<serviceCertificate findValue="RPKey" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My"/>
</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="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
答案 0 :(得分:2)
您是否设置了证书私钥的访问权限?私钥在默认情况下是安全的,因此只有管理员才能访问它们。您必须为运行服务的AppPool的帐户设置读取权限。
编辑:要设置权限,请打开MMC并为本地计算机添加管理单元。导航到个人&gt;证书&gt; RPKey并从上下文菜单中选择所有任务&gt;管理私钥。