views:

37

answers:

1

Hallo all,

I am writing service in internet scenario. I have to implement message encryption. I got everything but When I browse this service from IIS I am getting following exception.

Server Error in '/MyTestService' Application.

Keyset does not exist

Description: 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...............................................................

....................................................................

It seems to be certificate problem. Can somebody explain how to deal with Certificate stuff and please in detail. Just think that I am novice to Certificates.

<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>
+1  A: 

Did you set access permission to certificate private key? Private keys are secured by default so that only administrator can access them. You have to set read permission for the account running your service's AppPool.

Edit: To set permissions open MMC and add snap-in for your local machine. Navigate to Personal > Certificates > RPKey and from context menu select All tasks > Manage private keys.

Ladislav Mrnka
Is there any link, where I can read about public and private certificates or video tutorial?
Saghar
Terms private and public certificates are not probably correct. Certificate is standardized container for keys and related informations (like issuer, expiration, subject, serial number, etc). Certificate stored on server has to contain secret private key and public key. Certificate provided to clients has to contain only public key - Public Key Infrastructure.
Ladislav Mrnka