简体   繁体   English

WCF NetTcpBinding证书错误

[英]WCF NetTcpBinding Certificate error

I have a WebService that I am trying to use NetTCPBinding on. 我有一个要在其上使用NetTCPBinding的WebService。

here is my code for setting up the binding 这是我设置绑定的代码

  private static void Run()
    {
        try
        {

            //set up the address configuration procedure: create a URI to serve as the base address

            Uri baseAddress = new Uri("net.tcp://10.0.0.14:3790/Service/QBService");
            ServiceHost selfHost = new ServiceHost(typeof(QBService), baseAddress);

            try
            {

                NetTcpBinding myBinding = new NetTcpBinding();
                myBinding.Security.Mode = SecurityMode.Transport;
                myBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;

                myBinding.MaxReceivedMessageSize = 50000000;
                myBinding.MaxBufferPoolSize = 50000000;



                selfHost.AddServiceEndpoint(
                    typeof(IQBService),
                   myBinding,
                    "QBService");



                ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                smb.HttpGetEnabled = true;
                selfHost.Description.Behaviors.Add(smb);
                selfHost.Open();

                Console.WriteLine("The service is ready");

                bool terminate = false;
                //wait to read line as long as entertext is not equal to end
                while (!terminate)
                {
                    string entertext = Console.ReadLine();
                    if (entertext.Equals("end"))
                        terminate = true;
                    else
                        Console.WriteLine("\n Unknown Command \n");

                }



                selfHost.Close();

            }
            catch (CommunicationException ce)
            {

                Console.WriteLine(ce.Message, ce);
                selfHost.Abort();
            }

        }
      }

When I start the service I get this error 启动服务时出现此错误

"The service certificate is not provided. Specify a service certificate in serivcecredentials"

Do I have to use a certificate with this binding? 我必须使用具有此绑定的证书吗? or is there another way? 还是有另一种方法? Thanks! 谢谢!

You specified that Security.Mode = SecurityMode.Transport . 您指定了Security.Mode = SecurityMode.Transport If you don't want to use certificates, specify Security.Mode = SecurityMode.None instead to indicate no security. 如果您不想使用证书,请指定Security.Mode = SecurityMode.None表示没有安全性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM