微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

NetTcpBinding - 安全令牌请求包含无效或格式错误的元素

如何解决NetTcpBinding - 安全令牌请求包含无效或格式错误的元素

我有一个 WCF 服务设置,其中 Web 客户端使用通道工厂与 WCF 服务进行通信。我正在使用消息安全性进行身份验证和用户名客户端凭据类型。 我使用的绑定是“NetTcpBinding”

以下是我的配置设置:

客户: enter image description here

服务: enter image description here

频道工厂: enter image description here

现在我已经让这个设置在许多本地机器上运行得很好。 但是当我在服务器上运行此设置时,出现以下错误

消息:安全令牌请求包含无效或格式错误的元素。 堆栈跟踪: 异常:System.ServiceModel.Security.SecurityNegotiationException 消息:无法打开安全通道,因为与远程端点的安全协商失败。这可能是由于用于创建通道的 EndpointAddress 中缺少 EndpointIdentity 或指定的 EndpointIdentity 不正确。请验证 EndpointAddress 指定或隐含的 EndpointIdentity 正确识别远程端点。 结果:-2146233087 来源:System.ServiceModel.Internals 堆栈跟踪:在 System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult 结果) 在 System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult 结果) 在 System.ServiceModel.Channels.ServiceChannel.EndCall(String action,Object[] outs,IAsyncResult result) 在 System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.c__displayClass7_01.<CreateGenericTask>b__0(IAsyncResult asyncResult) at System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar,Func2 endFunction,Action1 endAction,Task1 promise,Boolean requiresSynchronization) --- End of stack trace from prevIoUs location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Web.Controllers.AccountController.<logon>d__6.MoveNext() in C:\agent\_work\1\s\ \1. Presentation Tier\Controllers\AccountController.cs:line 213 --- End of stack trace from prevIoUs location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__displayClass8_0.<BeginInvokeAsynchronousActionMethod>b__1(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__displayClass11_0.<InvokeActionMethodFilterasynchronouslyRecursive>b__0() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__displayClass11_2.<InvokeActionMethodFilterasynchronouslyRecursive>b__2() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__displayClass11_2.<InvokeActionMethodFilterasynchronouslyRecursive>b__2() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__displayClass11_2.<InvokeActionMethodFilterasynchronouslyRecursive>b__2() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__displayClass11_2.<InvokeActionMethodFilterasynchronouslyRecursive>b__2() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__displayClass11_2.<InvokeActionMethodFilterasynchronouslyRecursive>b__2() at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__displayClass3_6.<BeginInvokeAction>b__4() at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__displayClass3_1.<BeginInvokeAction>b__1(IAsyncResult asyncResult) DATA-System.ServiceModel.Diagnostics.ExceptionUtility.ExceptionStackAsstring:throw at System.ServiceModel.Security.sspiNegotiationTokenProvider.GetNextOutgoingMessageBody(Message incomingMessage,sspiNegotiationTokenProviderState sspiState) at System.ServiceModel.Security.IssuancetokenProviderBase1.GetNextOutgoingMessage(MessagecomingMessage,TnegotiationState ) 在 System.ServiceModel.Security.IssuancetokenProviderBase`1.DoNegotiation(TimeSpan timeout) 赶上

内部异常: 异常:System.ServiceModel.FaultException 消息:安全令牌请求包含无效或格式错误的元素。 行动:http://www.w3.org/2005/08/addressing/soap/fault 代码:System.ServiceModel.FaultCode 原因:安全令牌请求包含无效或格式错误的元素。 结果:-2146233087 来源:System.ServiceModel StackTrace:在 System.ServiceModel.Security.SecurityUtils.ThrowIfNegotiationFault(消息消息,端点地址目标) 在 System.ServiceModel.Security.sspiNegotiationTokenProvider.GetNextOutgoingMessageBody(MessageincomingMessage,sspiNegotiationTokenProviderState sspiState)

我已经尝试过的事情:

  1. 将我服务器的证书导入到我的本地计算机。使用该证书,它在我的本地运行良好。
  2. 在服务器中创建了其他证书。它不适用于服务器中的任何证书。
  3. 我在创建 ChannelFactory 时已经设置了“CertificateValidationMode = None”。所以这似乎不是证书问题。但是,我们不能完全排除这种情况。 任何帮助将不胜感激!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。