Hiya all,
I'm using the exact same routine in an app that I'm developing in B4J as I use in B4A, but for some strange reason if I set 'SMTPClient.UseSSL = True' in B4J, I get the following error whilst trying to send email through GMail. 'SMTPClient.UseSSL = True' is needed for my GMail account and in my B4A app 'SMTPClient.UseSSL = True' works perfect and it sends email 100% with no issues or errors.
'SMTPClient.UseSSL = True' in B4J causes this error...
I have read on the internet that Java might be missing a certificate or something like that...
I'm using the exact same routine in an app that I'm developing in B4J as I use in B4A, but for some strange reason if I set 'SMTPClient.UseSSL = True' in B4J, I get the following error whilst trying to send email through GMail. 'SMTPClient.UseSSL = True' is needed for my GMail account and in my B4A app 'SMTPClient.UseSSL = True' works perfect and it sends email 100% with no issues or errors.
B4X:
'Code
Dim SMTPClient As SMTP
SMTPClient.Initialize("smtp.gmail.com", 465, "[email protected]", "xxxxxxxxxx", "SMTP") 'xxxxxxxxxx is email password to bypass 2-Step verification on my Google account
SMTPClient.UseSSL = True '465
SMTPClient.HtmlBody = False
SMTPClient.Sender = "[email protected]"
SMTPClient.To.Add("[email protected]")
SMTPClient.Subject = "Home IP address has changed"
SMTPClient.Body = "Your new home IP address is " = NewIP
SMTPClient.Send
B4X:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
B4X:
Program started.
JobName = GetIP, Success = true
xxx.xxx.xx.255
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:1917)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:301)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:295)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1369)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:156)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:925)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:860)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1043)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1343)
at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:909)
at sun.security.ssl.AppInputStream.read(AppInputStream.java:105)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.fill(BufferedReader.java:161)
at java.io.BufferedReader.read(BufferedReader.java:182)
at org.apache.commons.net.io.CRLFLineReader.readLine(CRLFLineReader.java:59)
at org.apache.commons.net.smtp.SMTP.__getReply(SMTP.java:196)
at org.apache.commons.net.smtp.SMTP._connectAction_(SMTP.java:264)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:173)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:193)
at anywheresoftware.b4a.net.SMTPWrapper$1.run(SMTPWrapper.java:231)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
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: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:1351)
... 24 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:145)
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:131)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:382)
... 30 more
Error sending message
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
I have read on the internet that Java might be missing a certificate or something like that...
Last edited: