繁体   English   中英

无法创建从插件到Web服务的SSL / TLS安全通道

[英]Could not create SSL/TLS secure channel from plugin to web service

当我尝试使用服务参考中的方法时,插件出现问题。 我有一个客户端 ,该客户端将参数发送到Web服务 ,然后将这些参数发送到我的插件 ,然后我必须获取这些参数,然后使用Web引用方法将其发送到Web服务 要访问Web服务,我需要使用拥有最后一个Web服务的公司签发的证书。 我使用的代码是这样的:

BasicHttpsBinding binding = new BasicHttpsBinding
            {
                Security = new BasicHttpsSecurity
                {
                    Transport = new HttpTransportSecurity
                    {
                        ClientCredentialType = HttpClientCredentialType.Certificate
                    }
                }
            };

UploaderServiceClient client = new UploaderServiceClient(binding, new EndpointAddress(args.EndPoint));

client.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.LocaMachine, StoreName.My, X509FindType.FindBySerialNumber, args.SerialNum);

client.approveTransportDocument(appC, FileDesc);

使用此代码后,我得到一个异常:

The request was aborted: Could not create SSL/TLS secure channel.

最后一个Web服务可以正常工作,并且证书有效,因为如果我在表单上使用相同的代码,则可以正常工作。 编辑:我正在添加例外,我可能会有所帮助:

System.ServiceModel.Security.SecurityNegotiationException:无法使用权​​限“ imas-ws.vmi.lt”为SSL / TLS建立安全通道。 ---> System.Net.WebException:请求已中止:无法创建SSL / TLS安全通道。 在System.Net.HttpWebRequest.GetResponse()在System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)-内部异常堆栈跟踪的结尾-

服务器堆栈跟踪:位于System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException WebException,HttpWebRequest请求,HttpAbortReason abortReason)
位于System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)处于System.ServiceModel.Channels.RequestChannel.Request(Message,TimeSpan timeout)处于System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message) ,System.ServiceModel.Channels.ServiceChannel.Call(字符串操作,布尔型单向,ProxyOperationRuntime操作,Object [] ins,Object []超时,TimeSpan超时)在System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall ,ProxyOperationRuntime操作),位于System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage消息)

异常重新抛出为[0]:在System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&msgData,Int32类型)的System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)处。 u:\\ DPb \\ Plns \\ Eur_Iz \\ References \\ References中的Eur_Iz.Ie.UploaderServiceClient.submitTransportDocument(TransportDocument LocalTransportDocument,FileDescription ContextInformation,AdditionalContext AdditionalContext)处的UploaderService.submitTransportDocument(TransportDocument LocalTransportDocument,FileDescription ContextInformation,AdditionalContext AdditionalContext)。 Eur_Iz.ClientPlugin.DataHandling(IServicePluginArgs args)的第3295行

可能带有客户端证书或服务器证书。 可能是信任问题(客户端或服务器上缺少CA证书)。

启用事件日志中的CAPI2登录可能会给您答案,为什么它Could not create SSL/TLS secure channel. 默认情况下,禁用CAPI2日志。 启用它后,请尝试再次发出请求。 应该有一些错误事件,其中将包含有关原因的有用信息。 CAPI2事件日志

找到答案的问题是我必须授予Web服务使用证书的权限。 这是对我有帮助的链接: https : //serverfault.com/questions/131046/how-to-grant-iis-7-5-access-to-a-certificate-in-certificate-store/132791#132791

暂无
暂无

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

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