Android Question Migrating to OkHttp

copiloto

Member
Licensed User
Longtime User
Hello,

I'm modifying the code of my apps which use http protocol to OkHttp. Because of I'm having some troubles, have decided to use Erel's example code in order to be sure about right code.
I can't undestand where is my error when using my code instead of Erel's code:

B4X:
    job3.Initialize("Job3", Me)
    job3.Download("https://www.b4x.com/images/b4A_bubble.png")

My code:

B4X:
    job3.Initialize("Job3", Me)
    job3.Download("https://www.aemps.gob.es/cima/pdfs/es/ft/57819/FT_57819.pdf")

Then, capturing data is also done with Erel's method at JobDone module:

B4X:
     Dim out As OutputStream = File.OpenOutput(File.DirRootExternal, "medicine.pdf", False)
     File.Copy2(job.GetInputStream, out)
     out.Close '<------ very important

Running the code, a handshake error is showed:

javax.net.ssl.SSLHandshakeException: Handshake failed

It's sure that the error is not related to not using user nor password. It's not necessary at all, and never used it when running the previous http protocols.

Could someone help me a bit please?

Thanks in advance.
 

DonManfred

Expert
Licensed User
Longtime User
The Certificate your domain is using is not valid.
Use http:// or use the code version of okhttputils and initialize the client to accept all certificates (initializeacceptall or so)
 
Upvote 0

copiloto

Member
Licensed User
Longtime User
DonManfred, I appreciate your help. However, it doesn't works for mine. Perhaps server doesn't like new http protocols?.. The answer is still the same:

"javax.net.ssl.SSLHandshakeException: Handshake failed"

even modifying hc in HttpUtils2Service code like you suggest to me:

B4X:
    TempFolder = File.DirInternalCache
'    hc.Initialize("hc")
    hc.InitializeAcceptAll("hc")
    TaskIdToJob.Initialize

So, I'll have to return to previous code.

Best regards.
 
Upvote 0
Top