B4J Question ssl connection to a webserver

Michael1968

Active Member
Licensed User
Hi all,

I try to connect to a webserver via SSL to get status of a port.

I try this:
B4X:
Dim job As HttpJob
   
    'Init the job
       job.Initialize("getio", Me)
    'HTTP GET IO Port State
       job.Download("https://iot.seeed.cc/v1/node/resources?access_token=xxxxxxxxxx")
       job.GetRequest.SetHeader("Content-Type", "text/plain")
I get this 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.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1937)
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:1478)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:212)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:914)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1050)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1363)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1391)
I use httputils2 and OKhttputils2 with no successe.
with Firefox and chrome the URL works perfect.

Thanks
Michael
 

Michael1968

Active Member
Licensed User
The JVM doesn't recognize this certificate. You will need to use OkHttpUtils2 source code and change hc.Initialize with hc.InitializeAcceptAll (which means that it doesn't check the certificate).
thx a lot

now its working:)

best regards
Michael
 
Top