B4J Question [Solved]Java 11+B4J v6.80 BETA+B4JPackager11. Unable to find valid certification path to requested..

Dadaista

Active Member
Licensed User
Longtime User
Hi all

After B4J v6.80 BETA installation and pointed IDE path java to java 11, I get this error when my app try to send an email

Java Error.png


I copied jssecacerts file from java 8 folder to java 11 folder and that fixed the error.

I made an installation Setup from inno script generated by B4JPackager11. After installation of the setup generated, the error shows again.

Following instructions from @Erel, I copied jssecacerts file to the generated bin folder by B4JPackager11 and run debug_run.bat (without creating the setup). That did not fix the problem.


This is the output from debug_run.bat

B4X:
javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at java.base/sun.security.ssl.Alert.createSSLException(Unknown Source)
        at java.base/sun.security.ssl.TransportContext.fatal(Unknown Source)
        at java.base/sun.security.ssl.TransportContext.fatal(Unknown Source)
        at java.base/sun.security.ssl.TransportContext.fatal(Unknown Source)
        at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(Unknown Source)
        at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.onCertificate(Unknown Source)
        at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.consume(Unknown Source)
        at java.base/sun.security.ssl.SSLHandshake.consume(Unknown Source)
        at java.base/sun.security.ssl.HandshakeContext.dispatch(Unknown Source)
        at java.base/sun.security.ssl.HandshakeContext.dispatch(Unknown Source)
        at java.base/sun.security.ssl.TransportContext.dispatch(Unknown Source)
        at java.base/sun.security.ssl.SSLTransport.decode(Unknown Source)
        at java.base/sun.security.ssl.SSLSocketImpl.decode(Unknown Source)
        at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(Unknown Source)
        at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
        at b4j/org.apache.commons.net.smtp.AuthenticatingSMTPClient.performSSLNegotiation(Unknown Source)
        at b4j/org.apache.commons.net.smtp.AuthenticatingSMTPClient.execTLS(Unknown Source)
        at b4j/anywheresoftware.b4a.net.SMTPWrapper$1.run(Unknown Source)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)
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 java.base/sun.security.validator.PKIXValidator.doBuild(Unknown Source)
        at java.base/sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
        at java.base/sun.security.validator.Validator.validate(Unknown Source)
        at java.base/sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source)
        at java.base/sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source)
        at java.base/sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
        ... 19 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at java.base/sun.security.provider.certpath.SunCertPathBuilder.build(Unknown Source)
        at java.base/sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
        at java.base/java.security.cert.CertPathBuilder.build(Unknown Source)
        ... 25 more
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Setup created with Java 8 + the previous version of B4J + B4JPackager, runs fine.

How can I fix it?
 

Dadaista

Active Member
Licensed User
Longtime User
A simple solution will be to use a CustomTrustManager initialized with InitializeAcceptAll and set with SetCustomSSLTrunstManager.

Why is your mail server certificate not recognized?

I have no ideao_O

I do not know why is reconized before and not now when I change to java 11

From IDE runs fine.. :confused::confused::confused::confused:

Edit:
Domain hosted in 1&1 with SSL
 
Last edited:
Upvote 0

Dadaista

Active Member
Licensed User
Longtime User
Jssecacerts must to be copied to "temp/build/lib/security/" folder, generated by B4Jpackager11.
 
Upvote 0
Top