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 7086763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:35:25+00:00 2026-05-28T07:35:25+00:00

I am connecting to a duplex WCF service with an x509 cert, specifying the

  • 0

I am connecting to a duplex WCF service with an x509 cert, specifying the certificate details in the client config file like this:

<behaviors>
  <endpointBehaviors>
    <behavior name="ScannerManagerBehavior">
      <clientCredentials>
        <clientCertificate findValue="ClientName" x509FindType="FindBySubjectName" storeLocation="CurrentUser" storeName="My" />
        <serviceCertificate>
          <authentication certificateValidationMode="PeerTrust" />
        </serviceCertificate>
      </clientCredentials>
    </behavior>
  </endpointBehaviors>
</behaviors>

The code that then connects to the WCF service:

DuplexChannelFactory<IScannerManager> _smFactory 
= new DuplexChannelFactory<IScannerManager>(instanceContext, nameOfEndPoint);
var _commsChannel = _smFactory.CreateChannel();

I now need to specify the client certificate name that will be used programatically, in code. Is it possible for me to do that? I can see that I can create my own x509Certificate2 class, but I’m not sure how to change/set the findValue="clientName" bit…

Thanks

  • 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-05-28T07:35:26+00:00Added an answer on May 28, 2026 at 7:35 am

    Ok, so using the helpful comment from wal (thanks!) I managed to get it working. The trouble i faced was the discovery that if you are going to dynamically set any part of the client config in code, you can’t use any of the .config – you have to define it all in code. So it’s pretty much all or nothing. At least that was my experience.

    So, for me, I had to do this:

     var binding = new NetTcpBinding();
     binding.Security.Mode = SecurityMode.Transport;
     binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Certificate;
     binding.Security.Transport.ProtectionLevel = ProtectionLevel.EncryptAndSign;
     binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
    
     var identity = new DnsEndpointIdentity("localhost");
     Uri uri = new Uri("tcp:URI goes here");
     var address = new EndpointAddress(uri, identity, new AddressHeaderCollection());
    
     _smFactory = new DuplexChannelFactory<IScannerManager>(instanceContext, binding, address);
    
     _smFactory.Credentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindBySubjectName, "CustomCertificateNameHere");
     _commsChannel = _smFactory.CreateChannel();
    

    Which replaced my config.

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

Sidebar

Related Questions

I have a lot of client programs and one service. This Client programs communicate
Hi have quite a problem with an Service running WCF in duplex-mode. It leaks
The arhitecture: console application that contains a wcf duplex service; windows app consumers; every
I have a WCF chat service that accepts duplex tcp connections. A single duplex
I set up a small WCF service in Duplex mode. The service is consumed
Periodically, the duplex Net.TCP connection between our Silverlight application and our WCF web service
I'm about to start building an iPad client for an existing WCF service that
I am currently developing a duplex WCF service and I wish to test the
I have a working duplex WCF service with WSDualHttpBinding . My problem is figuring
Iam connecting my Android app to a wcf service, and in my Log.i I

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.