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

Discussion in 'Android Questions' started by DRU, Jul 28, 2019.

  1. DRU

    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 !
    Code:
    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
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    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.
     

    Attached Files:

    BillMeyer likes this.
  3. DRU

    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 !
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice