B4J Question jOkhttputils2 (2.62) jobdone response encrypted

kostefar

Active Member
Licensed User
Longtime User
Dear All,

I´m porting a b4a app to b4j, but I´m stuck now with where I´m logging into a service with jokhttputils, since what I´m getting back is a bunch of nonsense, eg.: �2���T���@�8�`2��)��R��%�l7�<U��^�ߔIKi�8/�� M8J�ya[&��9*�=Hbd�k��f\~ѓs�����C��ĥ��1
After making a POST request to the server (all using https). In the b4a version, I got plain text back from the server so I can only assume that this is the unecrypted data that I´m receiving.

A bit of my code:

B4X:
Sub login_A (parameters As String)
    Dim HttpJob As HttpJob
    HttpJob.Initialize("loginjob_A", Me)
    HttpJob.PostString(MainURL & "blahblah",parameters)

B4X:
Sub jobdone (Job As HttpJob)

    If Job.success = True Then
        Log ("jobname " & Job.JobName)
        Dim getstring As String = Job.GetString
        Log (getstring)


This is the 3rd packet that arrives, the first two packets show as decrypted the way they should - exactly like in b4a, although they are also encrypted. I can see that in a network monitor.

Any clues? Perhaps certificate related?
 
Last edited:

kostefar

Active Member
Licensed User
Longtime User

Hi Erel, thanks.

It does not happen in b4a, where I have this working fine.
What I did was copying everything to b4j, and changed next to nothing to make it work. After I ran it with the above result in b4j, I went back to b4a where it still works fine.
In b4a, I´m on genymotion where I´ve installed a certificate from fiddler, and I´ve done nothing yet with regards to this for java. That´s why I´d think that it´s related to the certificate.
 
Last edited:
Upvote 0

kostefar

Active Member
Licensed User
Longtime User
The certificate is only relevant during the SSL handshake.
Hmm ok, then it´s a bit of a mystery why this is happening.. I gotta get fiddler set up for java and see if what I´m sending/receiving to/from the server for some reason doesn´t look like what it does in b4a.
 
Last edited:
Upvote 0

nwhitfield

Active Member
Licensed User
Longtime User
I'd agree that it's possibly a result of the encryption settings on the server; check to make sure you have the latest versions of everything - I found, for instance, with with B4i iHttpUtils worked fine with gzip data, in B4A I had HttpUtils2 ticked in a project rather than OKHttpUtils2 which stopped it working.

If you have access to the server config, you could try looking for the output filters and disabling them, to see if that makes a difference. If it does, then it's definitely a gzip issue. The post at https://www.b4x.com/android/forum/threads/b4x-php-compatibility-thread.84473/#post-535387 shows the sort of lines you should be looking for in an Apache config file. To check this, just uncommment the AddOutputFilter line and the ones following it, the restart Apache. (If you're using a different server, sorry...)
 
Upvote 0

kostefar

Active Member
Licensed User
Longtime User

Thanks nwhitfield, still in the process of trying to get fiddler capturing what´s going on in java so I can compare it to the packages running in and out of the b4a project and see if there´s anything looking different.
The the server is not mine, so all issues need to be dealt with on client side.
I´ll report back as soon as I´m a step closer to the reason for this.
 
Upvote 0

kostefar

Active Member
Licensed User
Longtime User
Ok, found out what was wrong.
It was indeed certificate related, cause once I had the cert of fiddler added to java, and had the b4j https requests redirected to fiddler, it´s suddenly doing what it´s supposed to. Redirecting was done with:

B4X:
    SetSystemProperty("https.proxyHost", "127.0.0.1" )
    SetSystemProperty("https.proxyPort", "8888" )
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…