Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8499439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:40:03+00:00 2026-06-11T00:40:03+00:00

I’m trying to setup a WCF service with certificate authentication on both the client

  • 0

I’m trying to setup a WCF service with certificate authentication on both the client and server. I’m going through hell, looping through all the possible error messages.

The final objective here is to authenticate both parties with certificates. I’ll be issuing a specific certificate for every client which (hopefully) would allow me to tell them apart.

So far I have the following config files:

Server configuration file

<configuration>
    <system.serviceModel>
        <services>
            <service name="ServiceApiImplementation" behaviorConfiguration="myBehaviour">
                <host>
                    <baseAddresses><add baseAddress="http://localhost:9110/MyService"/></baseAddresses>
                </host>
                <endpoint address="" binding="wsHttpBinding" contract="IServiceAPI" bindingName="SOAP12Binding">
                    <identity>
                        <certificateReference findValue="ServerCertificate" storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectName"/>
                    </identity>
                </endpoint>
            </service>
        </services>
        <bindings>
            <wsHttpBinding>
                <binding name="SOAP12Binding" receiveTimeout="00:02:00" closeTimeout="00:01:00" openTimeout="00:01:00" sendTimeout="00:01:00">
                    <security mode="Message">
                        <message clientCredentialType="Certificate" negotiateServiceCredential="false" establishSecurityContext="false" />
                    </security>
                </binding>
            </wsHttpBinding>
        </bindings>
        <behaviors>
            <serviceBehaviors>
                <behavior name="myBehaviour">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                    <serviceCredentials>
                        <serviceCertificate findValue="ServerCertificate" storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectName" />
                        <clientCertificate>
                            <authentication certificateValidationMode="ChainTrust" revocationMode="NoCheck"/>
                        </clientCertificate>
                    </serviceCredentials>
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>
</configuration>

Client Configuration File

<system.serviceModel>
    <client>
        <endpoint address="http://localhost:9110/MyService" binding="wsHttpBinding" 
                  bindingConfiguration="SOAP12Binding_IServiceAPI" contract="IServiceAPI" 
                  behaviorConfiguration="behaviour1" name="SOAP12Binding_IServiceAPI">
            <identity>
                <!-- Value obtained when "Adding a Service Reference in visual studio" -->
                <certificate encodedValue="xxxxxxxxxxxxx" />
            </identity>
        </endpoint>
    </client>
    <behaviors>
        <endpointBehaviors>
            <behavior name="behaviour1">
                <clientCredentials>
                    <clientCertificate findValue="ClientCertificate" storeLocation="CurrentUser" storeName="My" x509FindType="FindBySubjectName"/>
                    <serviceCertificate>
                        <defaultCertificate findValue="ServerCertificate" storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectName" />
                        <authentication certificateValidationMode="ChainTrust" trustedStoreLocation="LocalMachine" revocationMode="NoCheck" />
                    </serviceCertificate>
                </clientCredentials>
            </behavior>
        </endpointBehaviors>
    </behaviors>
    <bindings>
        <wsHttpBinding>
            <binding name="SOAP12Binding_IServiceAPI">
                <security mode="Message">
                    <message clientCredentialType="Certificate"  negotiateServiceCredential="false" establishSecurityContext="false" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
</system.serviceModel>

I have generated a rootCA and a couple of certificates for both client and server, given the appropriate permissions and put them in the stores (both LocalMachine and CurrentUSer out of despair). To the best of my knowledge this bit is working.

The problems happen when calling the service. The latest error is:

An unsecured or incorrectly secured fault was received from the other
party. See the inner FaultException for the fault code and detail.

The message could not be processed. This is most likely because the
action ‘http://tempuri.org/IServiceAPI/MyMethod&#8217; is
incorrect or because the message contains an invalid or expired
security context token or because there is a m ismatch between
bindings. The security context token would be invalid if the service
aborted the channel due to inactivity. To prevent the service from
aborting idle sessions prematurely increase the Receive timeout on the
service endpoint’ s binding.

Or even (the previous error)

The identity check failed for the outgoing message. The expected
identity is
‘identity(http://schemas.xmlsoap.org/ws/2005/05/identity/right/possessproperty:
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn)’ for the
‘http://localhost:9110/MyService&#8217; target endpoint.

The error messages vary according to my experimentation in the config files. Right now both client and server are running on the same machine so, at least, I’d be expecting that each app would authenticate the other one through the rootCA.

Please note, I’m using Message Security and wsHttpBinding because they appeared to be the correct chouices. I don’t have any big restrictions except publishing a service that can be consumed by standard JAVA Frameworks.

Can anyone help me sort through this mess?

Any help would be grealty appreciated

Regards,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T00:40:04+00:00Added an answer on June 11, 2026 at 12:40 am

    I managed to solve my original problem.

    Regarding the two-way certificate authentication, I found that the following codeproject article provides a working demonstration: http://www.codeproject.com/Articles/36683/9-simple-steps-to-enable-X-509-certificates-on-WCF#Step%201:-%20Create%20client%20and%20server%20certificates

    Granted that this example uses peer trust, but so far I’ve never been able to have a working prototype working no matter what. From this point forward the only pitfalls I forsee are storing the certificate chain in the proper location and giving access to the private key to the user your project is running under. See this article for an explanation on how to give permissions to a certificate’s private key: http://msdn.microsoft.com/en-us/library/ff647171.aspx#Step6

    For the second part of the question: How to tell the clients certificates apart in a WCF service?, you can use the following code to obtain the client’s certificate thumbprint:

    X509Certificate2 certificate = null;
    
    if(ServiceSecurityContext.Current.AuthorizationContext.ClaimSets == null)
        throw new Exception("No claim set");
    
    foreach(var claim in ServiceSecurityContext.Current.AuthorizationContext.ClaimSets)
        if(claim is X509CertificateClaimSet)
        {
            X509CertificateClaimSet xcset = claim as X509CertificateClaimSet;
            certificate = xcset.X509Certificate;
            break;
        }
    
    if(certificate == null)
        throw new Exception("No X509 certificate found");
    
    string clientCertificateThumbprint = certificate.Thumbprint;
    

    This will get the client’s thumbprint that will be different for each client you issue a certificate to. Of course, all the other certificate data is available.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to loop through a bunch of documents I have to put
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.