简体   繁体   English

vb无法为SSL / TLS建立安全通道

[英]vb Could not establish secure channel for SSL/TLS

I am working on a project which I did not write, have inherited, and have an issue that I'm not sure quite how to solve. 我正在做一个我没有写,已经继承的项目,并且有一个我不确定如何解决的问题。 My background is not in .NET, so please excuse anything that doesn't sound right, as I may not know what the correct terminology should be. 我的背景不是.NET,所以请原谅听起来不正确的内容,因为我可能不知道正确的术语是什么。

We are using Visual Studio 2008 to compile a project that is running on Windows CE 6.0. 我们使用Visual Studio 2008编译在Windows CE 6.0上运行的项目。 We are using the Compact Framework v2.0. 我们正在使用Compact Framework v2.0。 The software is running on an Embedded processor in a network (WIFI) connected industrial environment. 该软件在联网(WIFI)连接的工业环境中的嵌入式处理器上运行。 The main UI is written in VB, and all of the supporting DLLs are written using C#. 主UI用VB编写,所有支持的DLL是使用C#编写的。

Up until now we've only been required to connect to http (non-secure) web addresses for GET requests. 到目前为止,我们只需要连接到GET请求的http(非安全)网址即可。 We now have a requirement to switch these addresses over to https (secure) for security's sake. 为了安全起见,我们现在需要将这些地址切换到https(安全)。

The HttpWebRequest is built/submitted from VB. HttpWebRequest是从VB构建/提交的。 When I provide the code with the https address, I get the "Could not establish secure channel for SSL/TLS" error that is in the subject. 当我向代码提供https地址时,出现主题中的“无法为SSL / TLS建立安全通道”错误。

Here is the code for that request: 这是该请求的代码:

                            Dim myuri As System.Uri = New System.Uri(sUrl)
                            Dim myHttpwebresponse As HttpWebResponse = Nothing
                            Dim myhttpwebrequest As HttpWebRequest = CType(WebRequest.Create(myuri), HttpWebRequest)
                            myhttpwebrequest.KeepAlive = False
                            myhttpwebrequest.Proxy.Credentials = CredentialCache.DefaultCredentials
                            myhttpwebrequest.ContentType = "text/xml"
                            myhttpwebrequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
                            myhttpwebrequest.AllowAutoRedirect = False
                            myhttpwebrequest.Timeout = 150000
                            Dim mycred As NetworkCredential = New NetworkCredential(username, password)
                            Dim myCredentialCache As CredentialCache = New CredentialCache()
                            myCredentialCache.Add(myuri, "Basic", mycred)
                            myhttpwebrequest.Credentials = myCredentialCache
                            myhttpwebrequest.Method = "GET"
                            myhttpwebrequest.ProtocolVersion = HttpVersion.Version10
                            ServicePointManager.CertificatePolicy = New AcceptServerNameMismatch
                            myHttpwebresponse = CType(myhttpwebrequest.GetResponse(), HttpWebResponse)

I have done quite a bit of reading over the last day or so that indicate that the CertificatePolicy is where I can override the ICertificatePolicy classes to essentially validate all SSL requests. 在过去的一天中,我已经做了大量的阅读工作,这表明CertificatePolicy是我可以覆盖ICertificatePolicy类以实质上验证所有SSL请求的地方。 Definitely not safe, and not ideal, but I'm not sure of another way to handle these requests. 绝对不安全,也不理想,但是我不确定要处理这些请求的另一种方法。

My class to do this is: 我的班级是:

Public Class MyCertificatePolicy
        Implements ICertificatePolicy

    Public Shared DefaultValidate As Boolean = True
    Public Sub trustedCertificatePolicy()
    End Sub

    Public Function CheckValidationResult(ByVal srvPoint As ServicePoint, _
       ByVal cert As X509Certificate, ByVal request As WebRequest, ByVal problem As Integer) _
       As Boolean Implements ICertificatePolicy.CheckValidationResult
        Return True
    End Function
End Class

Unfortunately when the response comes back, it never calls CheckValidationResult(). 不幸的是,当响应返回时,它永远不会调用CheckValidationResult()。 Thus, no validation and the error. 因此,没有验证和错误。

So my questions... 所以我的问题...

  • The "Right" way to do this according to everything that I've read is to use the ServerCertificateValidationCallback. 根据我已阅读的所有内容执行此操作的“正确”方法是使用ServerCertificateValidationCallback。 Unfortunately with the version of Compact Framework that we are using (maybe all?) it is not included. 不幸的是,我们正在使用的Compact Framework版本(也许是全部?)未包括在内。 Is there something that I'm missing that would cause that function not to get called? 我缺少某些东西会导致该函数无法调用吗?

  • Again, from what I've read, I believe that the Framework that we're running on doesn't support TLS v1.1 or v1.2. 同样,根据我的阅读,我相信我们运行的框架不支持TLS v1.1或v1.2。 Which most current servers are running. 当前哪些服务器正在运行。 Is there a way in VB to get around this? VB中有没有办法解决这个问题?

  • Is there another Request method that can be used? 还有其他可以使用的Request方法吗?

Any help or guidance as to where to go from here is greatly appreciated! 对于从这里出发的任何帮助或指导,我们将不胜感激!

You need to install the trusted root certificate on the device(s), that matches the SSL certificate on your server. 您需要在设备上安装与服务器上的SSL证书匹配的受信任的根证书。

Or change the certificate on the server to match one of the Trusted Roots on the device(s). 或更改服务器上的证书以匹配设备上的“受信任的根”之一。 By default, the devices ship with a very small number of trusted CAs, unlike desktop browsers that contain nearly every CA in the world. 默认情况下,设备附带的信任CA数量很少,而桌面浏览器几乎包含世界上每个CA。

暂无
暂无

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

相关问题 无法为SOAP调用建立SSL / TLS的安全通道 - Could not establish secure channel for SSL/TLS for SOAP call 无法为 SSL/TLS 安全通道建立信任关系 - SOAP 服务 - Could not establish trust relationship for the SSL/TLS secure channel - SOAP Service 无法为具有权限“epayment.dubai.ae”的 SSL/TLS 建立安全通道。 .NET 框架 4.5 - Could not establish secure channel for SSL/TLS with authority 'epayment.dubai.ae'. .NET Framework 4.5 WCF:无法为具有权限错误的SSL / TLS安全通道建立信任关系 - WCF : Could not establish trust relationship for the SSL/TLS secure channel with authority error VB。 NET:请求被中止:无法在 WebClient 上创建 SSL/TLS 安全通道 - VB. NET: The request was aborted: Could not create SSL/TLS secure channel on WebClient VB.NET Web服务无法连接:“无法创建SSL / TLS安全通道” - VB.NET Web Service connection impossible : “Could not create SSL/TLS secure channel” VB。 NET:请求被中止:无法创建 SSL/TLS 安全通道 - VB. NET: The request was aborted: Could not create SSL/TLS secure channel SOAP错误:请求已中止:无法创建SSL / TLS安全通道 - SOAP Error: The request was aborted: Could not create SSL/TLS secure channel XmlReader.Create错误“无法创建SSL / TLS安全通道” - XmlReader.Create error “Could not create SSL/TLS secure channel” 防止错误无法在某些服务器上创建 SSL/TLS 安全通道 - Prevent error could not create SSL/TLS secure channel on some servers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM