none
How to enable SSL & Certificate in case WCF TCP binding RRS feed

  • Question

  • any one can guide me how to enable SSL & Certificate in case WCF TCP binding. any idea.

    var baseAddress = "localhost";
    var factory = new DuplexChannelFactory<IMyWCFService>(new InstanceContext(SiteServer.Instance));
    factory.Endpoint.Address = new EndpointAddress("net.tcp://{0}:8000/".Fmt(baseAddress));
    var binding = new NetTcpBinding(SecurityMode.Message);
    binding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
    factory.Endpoint.Binding = binding;
    var u = factory.Credentials.UserName;
    u.UserName = userName;
    u.Password = password;
    return factory.CreateChannel();

    thanks

    Tuesday, April 1, 2014 2:19 PM

Answers

All replies

  • You must specify the certificate using the SetCertificate method. Please refer to the following links for more information:

    http://msdn.microsoft.com/en-us/library/ms789011.aspx
    http://msdn.microsoft.com/en-us/library/ms729700(v=vs.110).aspx

    • Marked as answer by Mou_kolkata Wednesday, April 2, 2014 1:52 PM
    Tuesday, April 1, 2014 2:35 PM
  • Hi,

    I see the you are using the username authentication. So when use the TCP SSL then the service must provide a service certificate, then you need to install a certificate in the server and conigure the service to use this certificate to prove it's identity and the service need to have the below behavior to specify the certificate for the service:

    <serviceBehaviors>
        <behavior>
          <serviceCredentials>
            <serviceCertificate findValue="localhost"
                                x509FindType="FindByIssuerName" />
          </serviceCredentials>
        </behavior>
    </serviceBehaviors>

    Also please have a look at the contents in the following articles: #netTcpBinding+Username/Password Authentication:
    http://albao.wordpress.com/2010/09/21/wcf-service-using-usernamepassword-authentication/ .

    #How to: WCF netTcpBinding and custom(username/password) Authentication:
    http://blog.clauskonrad.net/2011/03/how-to-wcf-and-custom-authentication.html .

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, April 2, 2014 7:06 AM
    Moderator
  • i am new in wcf and also to be very honest that i have basic problem to understand the SSL & certificate.

    1) i like to know that when we enable SSL then every time we need to use certificate or the same way when we attach certificate with wcf then SSL will be used implicitly.

    2) SSL & Certificate both are same or different in concept ?

    3) when we self host wcf service then can we enable SSL or certificate...which one will be applicable ?

    4) tcp binding for certificate is not related with http. so when we work with tcp binding then can we enable SSL for tcp binding.

    5) what is difference between SSL & Certificate ?

    i know i asked very basic quetion. if possible please explain all my points in details to clear my doubts. thanks

    Wednesday, April 2, 2014 8:51 AM
  • thanks for the Answer.

    i am new in wcf and also to be very honest that i have basic problem to understand the SSL & certificate.

    1) i like to know that when we enable SSL then every time we need to use certificate or the same way when we attach certificate with wcf then SSL will be used implicitly.

    2) SSL & Certificate both are same or different in concept ?

    3) when we self host wcf service then can we enable SSL or certificate...which one will be applicable ?

    4) tcp binding for certificate is not related with http. so when we work with tcp binding then can we enable SSL for tcp binding.

    5) what is difference between SSL & Certificate ?

    6) when we use certificate at service end then client end which consume & call the service they always need to install certificate. if not then when client need to install certificate & when not required. one guy told me that client need to install certificate only when mutual authentication is required but i do not know about what mutual authentication ?

    i know i asked very basic question. if possible please explain all my points in details to clear my doubts. thanks

    Wednesday, April 2, 2014 8:54 AM
  • thanks for the Answer.

    i am new in wcf and also to be very honest that i have basic problem to understand the SSL & certificate.

    1) i like to know that when we enable SSL then every time we need to use certificate or the same way when we attach certificate with wcf then SSL will be used implicitly.

    2) SSL & Certificate both are same or different in concept ?

    3) when we self host wcf service then can we enable SSL or certificate...which one will be applicable ?

    4) tcp binding for certificate is not related with http. so when we work with tcp binding then can we enable SSL for tcp binding.

    5) what is difference between SSL & Certificate ?

    6) when we use certificate at service end then client end which consume & call the service they always need to install certificate. if not then when client need to install certificate & when not required. one guy told me that client need to install certificate only when mutual authentication is required but i do not know about what mutual authentication ?

    i know i asked very basic question. if possible please explain all my points in details to clear my doubts. thanks

    Wednesday, April 2, 2014 8:54 AM