Arquivo da tag: Certificado

Está com esse problema “Caused by: sun.security.provider.certpath.SunCertPathBuilderException”?

Esse problema me deu muita dor de cabeça para resolver, o problema era simples queria enviar um email com uma programa Java simples e dava esse erro:

java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is: 
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.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:286) 
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184) 
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322) 
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source) 
 
at java.lang.Thread.run(Thread.java:662) 
Caused by: 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 com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174) 
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1649) 
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:241) 
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:235) 
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1206) 
at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:136) 
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:593) 
at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:529) 
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:893) 
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1138) 
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:632) 
at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59) 
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65) 
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123) 
at java.io.DataOutputStream.flush(DataOutputStream.java:106) 
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:211) 
... 8 more 
Caused by: 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.validator.PKIXValidator.doBuild(PKIXValidator.java:323) 
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:217) 
at sun.security.validator.Validator.validate(Validator.java:218) 
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:126) 
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:209) 
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:249) 
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1185) 
... 19 more 
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:174) 
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:238) 
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:318) 
... 25 more

Porém para resolver precisa primeiro baixar o OpenSSL para Windows, com Linux ou MacOS não precisa baixar.
Próximo passo é só seguir esse tutorial Import Gmail certificate into java keystore.