【问题标题】:Help needed to secure my WCF service using Certificate使用证书保护我的 WCF 服务所需的帮助
【发布时间】:2010-08-18 11:18:30
【问题描述】:

大家好,

我正在互联网场景中编写服务。我必须实现消息加密。我得到了一切,但是当我从 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>

【问题讨论】:

    标签: wcf wcf-security


    【解决方案1】:

    您是否设置了证书私钥的访问权限?默认情况下,私钥是受保护的,因此只有管理员才能访问它们。您必须为运行您服务的 AppPool 的帐户设置读取权限。

    编辑:要设置权限,请打开 MMC 并为您的本地计算机添加管理单元。导航到个人 > 证书 > RPKey,然后从上下文菜单中选择所有任务 > 管理私钥。

    【讨论】:

    • 是否有任何链接,我可以在其中阅读有关公共和私人证书或视频教程的信息?
    • 术语私有和公共证书可能不正确。证书是密钥和相关信息(如颁发者、到期、主题、序列号等)的标准化容器。存储在服务器上的证书必须包含秘密私钥和公钥。提供给客户的证书必须仅包含公钥 - 公钥基础设施。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-21
    • 2011-05-06
    • 2014-03-28
    相关资源
    最近更新 更多