Spanish error en accesos ssl

cervantico

Member
Licensed User
Longtime User
me sale el siguiente error al intentar acceder al servidor pop3:
javax.net.ssl.SSLException: Connection has been shutdown: 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

algún alma caritativa puede decirme como solucionarlo, el programa funcionaba correctamente en un principio, pero después y sin hacerle ninguna modificación dejo de funcionar

muchas gracias de antemano
fernando
 

bgsoft

Well-Known Member
Licensed User
Longtime User
Hola

Si no tocaste nada, tienes el 99,99% de posibilidades de que sea el servidor, y mas por ese mensaje que te da: Connection has been shutdown, y este te indica que no es válido el path unable to find valid certification path to requested target.

Por otro lado sin codigo es dificil saber si es un error de la aplicación, hazlo ejecutar en Debug(rapid) y veras exactamente donde da el error.

saludos
 

cervantico

Member
Licensed User
Longtime User
Gracias Jesús, el código lo baje de los foros y funciono bien desde el principio, utiliza el modulo mailparser, en el modo debug me sigue dando el mismo error "(SunCertPathBuilderException) sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target" más esto al final del log "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",la verdad es que me tiene muy agobiado este problema, he probado en otros ordenadores donde antes funciono y ahora casca....
 

cervantico

Member
Licensed User
Longtime User
de todas formas el codigo del cuerpo principal del programa es el siguiente:

Sub MailTimer_Tick
Log("Checking mails")
aviso.Text="Comprobando solicitudes"
pop.Initialize(popServer, popPort, user, password, "pop")
pop.UseSSL = True
pop.ListMessages
progress1.Visible = True
End Sub

Sub pop_ListCompleted (Success As Boolean, Messages As Map)

progress1.Visible = False
If Success Then
If Messages.Size > 0 Then
progress1.Visible = True
LogMessage("Found messages: " & Messages.Size)
aviso.Text=Messages.Size & " Solicitudes nuevas"
For Each id As Int In Messages.Keys
pop.DownloadMessage(id, False) 'message will be deleted from the server
Next
lastMsgId = id
Else
Log("No messages.")
aviso.Text="No hay solicitudes nuevas"

End If
Else
LogMessage("Error: " & LastException)
End If
pop.Close 'this will close the connection after the messages were downloaded.
End Sub

Sub POP_DownloadCompleted (Success As Boolean, MessageId As Int, MessageText As String)
'Dim x As FileChooser
If Success = False Then
Log(LastException.Message)
Else
Log(MessageId)
'Parse the mail
Dim m As Message
m = MailParser.ParseMail(MessageText, File.DirTemp)
LogMessage("Asunto: " & m.Subject&CRLF&m.Body)
lista.Items.Add(m.Subject&" "&m.Body)
rec=m.Subject&" / "&m.Body'&CRLF

'list1.Add(rec)
'Dim Out As OutputStream =File.OpenOutput(File.DirApp,"ped"&DateTime.GetMonth(DateTime.Now)&".txt",True)
'File.WriteString(File.DirApp,"ped"&DateTime.GetMonth(DateTime.Now)&".txt",rec)
'historial
HandleMessage(m)
End If
If MessageId = lastMsgId Then progress1.Visible = False
End Sub

si necesitas ver el código del mailparser dímelo y lo publico, necesito solucionar este problema con urgencia.
gracias de nuevo
 

bgsoft

Well-Known Member
Licensed User
Longtime User
Hola

Asi a simple vista es dificil ver que ocurre, te dije lo debug rapid para que ejecutes paso a paso y asi veas en que linea de programa da el error, asi podras tener una idea aproximada del error.
Tambien otra cosa que puede pasar es que hayas actualizado la versión de B4A o de las librerias y por eso antes iba y ahora no.

Llamar al servidor desde un timer no es buena cosa, podria ser que dependiendo del tiempo de ese temporizador hagas llamadas frecuentes y por eso de el error, lo mejor es crear un servicio. Y si no, ponle alguna variable para que no entre si no acabó.
Tambien ten en cuenta que el temporiador lo tienes que definir en el Sub Process_Globals, por que si no cada vez que salgas y entres en la aplicación crearas un evento nuevo del temporizador, y eso podria ser otra causa del error. Tambien tienes que inicializar el temporizador en Sub Activity_Create(FirstTime As Boolean) pero cuando FirstTime = True, para que no pase lo mismo de arriba.

Acuerdate de meter el codigo pulsando el quinto icono por la derecha, asi el codigo es mas entendible.

Aun así, sigo pensando que hay un problema en el servidor, has probado desde otra aplicación?

Saludos
 

cervantico

Member
Licensed User
Longtime User
Hola de nuevo Jesús, gracias por el interés que muestras en ayudarme,pego a continuación todo lo que sale en el log, no he actualizado el B4J desde que lo instale, y como dije antes funcionaba correctamente, creo que el problema tiene que ver con los certificados de seguridad ssl. este es el log:

Program started.
2014-08-04 12:21:24.420:INFO::JavaFX Application Thread: Logging initialized @3128ms
Checking mails
javax.net.ssl.SSLException: Connection has been shutdown: 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.SSLSocketImpl.checkEOF(SSLSocketImpl.java:1476)
at sun.security.ssl.SSLSocketImpl.checkWrite(SSLSocketImpl.java:1488)
at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:70)
at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291)
at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:295)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)
at java.io_OutputStreamWriter.flush(OutputStreamWriter.java:229)
at java.io.BufferedWriter.flush(BufferedWriter.java:254)
at org.apache.commons.net.pop3.POP3.sendCommand(POP3.java:239)
at org.apache.commons.net.pop3.POP3.sendCommand(POP3.java:282)
at org.apache.commons.net.pop3.POP3Client.logout(POP3Client.java:235)
at anywheresoftware.b4a.net.POPWrapper.CloseNow(POPWrapper.java:302)
at anywheresoftware.b4a.net.POPWrapper$1.run(POPWrapper.java:147)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
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 sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1884)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:270)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1341)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:153)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1016)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:882)
at sun.security.ssl.AppInputStream.read(AppInputStream.java:102)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.fill(BufferedReader.java:154)
at java.io.BufferedReader.read(BufferedReader.java:175)
at org.apache.commons.net.io.CRLFLineReader.readLine(CRLFLineReader.java:59)
at org.apache.commons.net.pop3.POP3.__getReply(POP3.java:114)
at org.apache.commons.net.pop3.POP3._connectAction_(POP3.java:151)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:173)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:193)
at anywheresoftware.b4a.net.POPWrapper.connectIfNeeded(POPWrapper.java:114)
at anywheresoftware.b4a.net.POPWrapper.access$2(POPWrapper.java:107)
at anywheresoftware.b4a.net.POPWrapper$1.run(POPWrapper.java:133)
... 5 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:385)
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:326)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:231)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:126)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1323)
... 26 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:196)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:268)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:380)
... 32 more
Error: (SunCertPathBuilderException) sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
javax.net.ssl.SSLException: Connection has been shutdown: 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.SSLSocketImpl.checkEOF(SSLSocketImpl.java:1476)
at sun.security.ssl.SSLSocketImpl.checkWrite(SSLSocketImpl.java:1488)
at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:70)
at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291)
at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:295)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)
at java.io_OutputStreamWriter.flush(OutputStreamWriter.java:229)
at java.io.BufferedWriter.flush(BufferedWriter.java:254)
at org.apache.commons.net.pop3.POP3.sendCommand(POP3.java:239)
at org.apache.commons.net.pop3.POP3.sendCommand(POP3.java:282)
at org.apache.commons.net.pop3.POP3Client.logout(POP3Client.java:235)
at anywheresoftware.b4a.net.POPWrapper.CloseNow(POPWrapper.java:302)
at anywheresoftware.b4a.net.POPWrapper$4.run(POPWrapper.java:286)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
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 sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1884)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:270)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1341)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:153)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1016)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:882)
at sun.security.ssl.AppInputStream.read(AppInputStream.java:102)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.fill(BufferedReader.java:154)
at java.io.BufferedReader.read(BufferedReader.java:175)
at org.apache.commons.net.io.CRLFLineReader.readLine(CRLFLineReader.java:59)
at org.apache.commons.net.pop3.POP3.__getReply(POP3.java:114)
at org.apache.commons.net.pop3.POP3._connectAction_(POP3.java:151)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:173)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:193)
at anywheresoftware.b4a.net.POPWrapper.connectIfNeeded(POPWrapper.java:114)
at anywheresoftware.b4a.net.POPWrapper.access$2(POPWrapper.java:107)
at anywheresoftware.b4a.net.POPWrapper$1.run(POPWrapper.java:133)
... 5 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:385)
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:326)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:231)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:126)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1323)
... 26 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:196)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:268)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:380)
... 32 more
javax.net.ssl.SSLException: Connection has been shutdown: 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.SSLSocketImpl.checkEOF(SSLSocketImpl.java:1476)
at sun.security.ssl.SSLSocketImpl.checkWrite(SSLSocketImpl.java:1488)
at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:70)
at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291)
at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:295)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)
at java.io_OutputStreamWriter.flush(OutputStreamWriter.java:229)
at java.io.BufferedWriter.flush(BufferedWriter.java:254)
at org.apache.commons.net.pop3.POP3.sendCommand(POP3.java:239)
at org.apache.commons.net.pop3.POP3.sendCommand(POP3.java:282)
at org.apache.commons.net.pop3.POP3Client.logout(POP3Client.java:235)
at anywheresoftware.b4a.net.POPWrapper.CloseNow(POPWrapper.java:302)
at anywheresoftware.b4a.net.POPWrapper$4.run(POPWrapper.java:286)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
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 sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1884)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:270)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1341)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:153)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1016)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:882)
at sun.security.ssl.AppInputStream.read(AppInputStream.java:102)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.fill(BufferedReader.java:154)
at java.io.BufferedReader.read(BufferedReader.java:175)
at org.apache.commons.net.io.CRLFLineReader.readLine(CRLFLineReader.java:59)
at org.apache.commons.net.pop3.POP3.__getReply(POP3.java:114)
at org.apache.commons.net.pop3.POP3._connectAction_(POP3.java:151)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:173)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:193)
at anywheresoftware.b4a.net.POPWrapper.connectIfNeeded(POPWrapper.java:114)
at anywheresoftware.b4a.net.POPWrapper.access$2(POPWrapper.java:107)
at anywheresoftware.b4a.net.POPWrapper$1.run(POPWrapper.java:133)
... 5 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:385)
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:326)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:231)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:126)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1323)
... 26 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:196)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:268)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:380)
... 32 more

como puedes ver es largo, farragoso y no se por donde meterle mano, mailparser es un modulo que es llamado cada vez que se encuentra un nuevo correo y no he cambiado nada del código de ejemplo que baje, en fin Jesús que no se que produce el error en una aplicación tan simple.
gracias por tu paciencia y colaboración
 

bgsoft

Well-Known Member
Licensed User
Longtime User
Hola

No sabia que era en B4J, si es asi en la cabecera del post tendrias que ponerlo, asi podras recibir mejor ayuda. Y basado en esto, por que no pones el mismo codigo(similar) en B4A y pruebas? quizas veas mejor el error.
Por otro lado no me has dicho si lo has ejecutado en modo debug y paso a paso, asi se resuelven muchos problemas por que de antemano sabes en que sentencia da el error

Saludos
 
Top