0
I’m trying to consume the zip code webservice
I’m using Java Web - JSF with Wildffly10
For this I am using the following code.
String URL_WEBSERVICECEP = "https://viacep.com.br/ws/[CEP]/json/";
String urlCep = URL_WEBSERVICECEP.replace("[CEP]", "88701650");
System.out.println("------ url : "+urlCep);
URL url = new URL(urlCep);
HttpsURLConnection con = (HttpsURLConnection)url.openConnection();
InputStream conS = con.getInputStream();
But this giving the following error.
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.getSLException(Alerts.java:192) at sun.security.ssl.SLSocketImpl.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:1509) at sun.security.ssl.ClientHandshaker.processMessage(Clienthandshaker.java:216) at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979) at sun.security.ssl.Handshaker.process_record(Handshaker.java:914) at sun.security.ssl.SLSocketImpl.readRecord(Sslsocketimpl.java:1062) at sun.security.ssl.SLSocketImpl.performInitialHandshake(Sslsocketimpl.java:1375) at sun.security.ssl.SLSocketImpl.startHandshake(Sslsocketimpl.java:1403) at sun.security.ssl.SLSocketImpl.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:1513) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Httpurlconnection.java:1441) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Httpsurlconnectionimpl.java:254) at br.com.transportesalvorada.security.Controll.Usuario_mb.main(Usuario_mb.java:141) Caused by: sun.security.Validator.Validatorexception: PKIX path failed building: sun.security.Provider.certpath.Suncertpathbuilderexception: Unable to find Valid Certification path to requested target at sun.security.Validator.PKIXValidator.doBuild(Pkixvalidator.java:387) at sun.security.Validator.PKIXValidator.engineValidate(Pkixvalidator.java:292) at sun.security.Validator.Validator.validate(Validator.java:260) at sun.security.ssl.X509trustmanagerimpl.validate(X509trustmanagerimpl.java:324) at sun.security.ssl.X509trustmanagerimpl.checkTrusted(X509trustmanagerimpl.java:229) at sun.security.ssl.X509trustmanagerimpl.checkServerTrusted(X509trustmanagerimpl.java:124) at sun.security.ssl.ClientHandshaker.serverCertificate(Clienthandshaker.java:1491) ... 13 more Caused by: sun.security.Provider.certpath.Suncertpathbuilderexception: Unable to find Valid Certification path to requested target at sun.security.Provider.certpath.Suncertpathbuilder.build(Suncertpathbuilder.java:141) at sun.security.Provider.certpath.Suncertpathbuilder.engineBuild(Suncertpathbuilder.java:126) at java.security.cert.CertPathBuilder.build(Certpathbuilder.java:280) at sun.security.Validator.PKIXValidator.doBuild(Pkixvalidator.java:382) ... 19 more
As I understand it has no digital certificate, I really do not possess certificate.
The interesting thing is that if you test directly in the browser works.
I consume this webservice on my system and this also has no digital certificate.
– Andrew Ribeiro