ASP.NET 无法通过 SSL 连接到 Oracle 数据库,而控制台应用程序可以成功连接的情况可能有以下几个原因:
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
防火墙问题:ASP.NET 所在的服务器可能有防火墙设置,阻止了与 Oracle 数据库服务器的 SSL 连接。可以尝试与服务器管理员联系,检查并解决防火墙问题。
SSL 版本不匹配问题:ASP.NET 和 Oracle 数据库服务器可能使用不同版本的 SSL。可以尝试在 ASP.NET 的代码中指定使用特定的 SSL 版本,例如:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
请根据具体情况逐个尝试以上解决方法,以找到适用于您的情况的解决方案。