【问题标题】:WCF NetTcpBinding Certificate errorWCF NetTcpBinding 证书错误
【发布时间】:2010-08-30 15:38:03
【问题描述】:

我有一个正在尝试使用 NetTCPBinding 的 WebService。

这是我设置绑定的代码

  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();
            }

        }
      }

当我启动服务时出现此错误

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

我必须使用带有此绑定的证书吗?还是有其他方法? 谢谢!

【问题讨论】:

    标签: c# wcf wcf-binding


    【解决方案1】:

    您指定了Security.Mode = SecurityMode.Transport。如果您不想使用证书,请指定 Security.Mode = SecurityMode.None 以表示没有安全性。

    【讨论】:

    • 所以运输我必须使用证书?我们确实想要某种安全性,但还有其他选择还是我应该只做证书?谢谢。
    • 正确设置安全网络服务的唯一方法是使用证书。
    猜你喜欢
    • 2014-08-25
    • 1970-01-01
    • 2010-10-27
    • 1970-01-01
    • 2011-11-03
    • 1970-01-01
    • 2010-10-08
    • 1970-01-01
    • 2012-12-11
    相关资源
    最近更新 更多