工作中的问题积累

2021年9月

java使用HttpURLConnection 去下载资源。

  • 有一天突然就出现这个bug了。经过查询是ssl证书问题。 首先下载的资源是 https:// 的资源,但这个资源的ssl证书已经过期,或者是错误的,不授信的。这种情况你看很多网上说去改代码。我就想说这是资源的问题,1.修改成http:// 2.更新证书。代码中可以做一个简单的try catch操作,抛出一个对方需要更新证书的信息就可以了
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
        at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949)
        at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
        at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)
        at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1514)
        at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
        at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1026)
        at sun.security.ssl.Handshaker.process_record(Handshaker.java:961)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)
        at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
        at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1546)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
        at com.agile.cloud.util.FileUploadUtil.getImageFromNetByUrl(FileUploadUtil.java:620)
        at com.agile.cloud.service.ContractInfoNewServiceImpl.uploadContractUrl(ContractInfoNewServiceImpl.java:2767)
        at com.agile.cloud.service.ContractInfoNewServiceImpl$$FastClassBySpringCGLIB$$f53bf706.invoke(<generated>)
上一篇:sun公司


下一篇:SUN 公司