打开输入流时发生 SSL 错误

发布于 2024-12-10 21:26:51 字数 804 浏览 0 评论 0原文

我想我想了解 SSL 是如何工作的,我有基于 grails 的应用程序作为应用程序过程的一部分,我们必须打开与第 3 方应用程序的“https”连接。 但遇到以下异常

"sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target"

虽然与 URL 的连接工作正常,但当我尝试打开输入流以读取数据时会发生错误。问题是,如果存在证书问题,我在打开连接时应该不会遇到问题吗? 附上代码片段

try{
            URL url= new URL("https://.../..")
                def c = url.openConnection()
                println("connection successful with Merchant")
            def result = c.inputStream.text?.trim() // results in error
            println(result)
        }
        catch (Exception exp){
            println("error !!!")
                println(exp.getMessage())
        }

I guess I am trying to understand how SSL works, I have grails based application as part of application process we have to open "https" connection to a 3rd party application.
But running into following exception

"sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target"

Though connection to the URL works fine but error happens when I try to open input Stream for reading data. Question is if there is certificate problem shouldn't I have problem while opening connection ?
code snippet is attached

try{
            URL url= new URL("https://.../..")
                def c = url.openConnection()
                println("connection successful with Merchant")
            def result = c.inputStream.text?.trim() // results in error
            println(result)
        }
        catch (Exception exp){
            println("error !!!")
                println(exp.getMessage())
        }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

如果没结果 2024-12-17 21:26:51

对于刚开始使用 SSL 和证书管理的人来说,这是一个非常常见的问题。我在我的博客上题为“导入非众所周知的证书”的文章中用非常详细的示例和命令回答了这个问题 AllInGeek.com

This is a very common problem for people starting out with SSL and certificate management. I answer this question with very detailed examples and commands in an article titled, "Importing non-well known certificates" on my blog AllInGeek.com.

糖果控 2024-12-17 21:26:51

这仅意味着您要连接的 Web 服务器或 URL 没有来自授权 CA 的有效证书。

您可以通过另一个 ssl 站点验证这一点
或按照此处的步骤操作:

http://www.java-samples.com/showtutorial .php?tutorialid=210

通过导入服务器证书来解决该问题。

This simply means that the web server or the URL you are connecting to does not have a valid certificate from an authorized CA.

You could verify this with another ssl site
or follow the steps here:

http://www.java-samples.com/showtutorial.php?tutorialid=210

to work around the issue by importing the servers certificate.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文