Android Question Looking for in code soltutions to handle SSLHandshakeException

Cadenzo

Active Member
Licensed User
Longtime User
With older devices (<= Android 7.0?) the connection gets an SSLHandshakeException. It seems to be the free "let's encrypt" certificate, which older androids can't deal with.
Here I found a good solution, ignoring the certificate with "HU2_ACCEPTALL" in Build Configurations / Conditional Symbols, that works. But I don't want to ignore it in any case, only with older devices, if there is no other way!
Can I do this also in source-code, if I get this error message, calling my site again, but only this time ignoring the certificate?

B4X:
    Dim job As HttpJob
    job.Initialize("", Me)
    job.PostString("https://myWebsite...", "my request...") 'call the site with a request
    job.GetRequest.SetContentType("text/plain")
    
    Wait For (job) JobDone(job As HttpJob) 'auf Serverantwort warten
    If job.Success Then
        '...'
    Else 'Connection-Error
        'SSLHandshakeException with older devices 'Compiler Option HU2_ACCEPTALL
        Log("Connection-Error: " & job.ErrorMessage)
    End If
    job.Release
 

Cadenzo

Active Member
Licensed User
Longtime User
So you would suggest to use HU2_ACCEPTALL in any case with HttpJob to prevent this error in older devices?
 
Upvote 0
Top