I am trying to call a webservice hosted on the local network using https secure connection, first it gave the exception that HostNameUnresolved, so I used the ip address instead of the name, now I am getting the following error:
Error in geting tags.=javax.net.ssl.SSLException: hostname in certificate didn't match: <10.100.248.99> !=
I have already added the intermediate and root certificates to the android trusted list.
Could anyone give me a solution to access a securely hosted webservice on local network using host name not ip address?
As mentioned by others, you need a couple of things to be able to connect your web-service:
– the emulator to know what is the IP address of the server you need to connect to
– the server name URL you connect through HTTPS must resolve to the domain of the SSL certificate
To do that, you need to:
writeableFrom your desktop shell (example for linux but would be similar on windows, and assume the Android sdk is intalled on
/android-sdk):where NexusS is the AVD name of your device. You
MUSTstart the emulator from command line or you will get an error in later steps.Now open another shell terminal and get your emulator /system/etc/hosts file:
The
remountis to set the partitions writeable. Thepullcommand above copies the hosts file to/tmp/hostsof your desktop.From the desktop edit the /tmp/hosts file to match your need, i.e. if the Web Service is https://www.example.com/foo and IP is 192.168.1.10:
Then push it back to the emulator:
You should be able to connect to the web-service now.
Note that you could still have error in case of a self-signed certificate.
The image below is before editing the

hostsfile:After editing:
