Android Question HTTPS Get/Post request error : Trust anchor for certification path not found

DRU

Member
Licensed User
Hi all,
Cannot figure out how to send get/post request to an https server.
Rigth now i'm experiencing with my own local server which has a private certificate installed. Everything is ok if i test with postman.
I'm using OkHttpUtils2 version 2.82.
I've found several posts recommanding to use .initializeAcceptAll but i can't find this option when typing job.
what's wrong ?
thank's for you'r help !
B4X:
Sub sendBooking2Api(record As Booking)
    Dim job As HttpJob
    job.Initialize("",Me)
 
    job.PostString("https://" & Globals.Api_MainAddress2 & "/bookings/store",record.GetApiString())
    LogColor("https://" & Globals.Api_MainAddress2 & "/bookings/store" & "?" & record.GetApiString(),Colors.Magenta)

    wait for (job) JobDone (job As HttpJob)
    If job.Success Then
        Log(job.GetString)
        record.IsSent2Api()
    Else
        
    End If
End Sub
 

Erel

Administrator
Staff member
Licensed User
what's wrong ?
1. You are not calling Job.Release.
2. You haven't posted the error message.
3. I will assume that the certificate is rejected (which is the correct behavior for unrecognized certificates).

The attached untested library is a modified version of OkHttpUtils2 (based on 2.82) where OkHttp is initialized to accept all certificates. Copy it to the internal libraries folder.
 

Attachments

DRU

Member
Licensed User
Many Many thank's Erel !!!
Now it works fine with the version of library you have attached.
I'll switch back to previous version when i'll be ready to publish my Api on a server with a public SSL certificate.

THX A LOT !
 
Top