I tried to fix this from android code by adding an "accept all certificate" rule. But all the effort from android side was worthless.
Finally making a CNAME in registrar entry that ensured that all requests go to the same IP address fixed the problem