[英]WCF NetTcpBinding Certificate error
我有一個要在其上使用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"
我必須使用具有此綁定的證書嗎? 還是有另一種方法? 謝謝!
您指定了Security.Mode = SecurityMode.Transport
。 如果您不想使用證書,請指定Security.Mode = SecurityMode.None
表示沒有安全性。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.