3

Following exception happens when OkHttp tries to connect to a server using IP address:

javax.net.ssl.SSLPeerUnverifiedException: Hostname 195.168.2.68 not verified:
       certificate: sha256/rxO7r+KJOj2iTLR+MPWF7rNV45BYYQKvhlsb4K6yHXE=
       DN: CN=test sandbox,OU=it,O=abc,L=newyork,ST=western,C=us
       subjectAltNames: []

A server has a self-signed SSL Certificate which was generated for server's IP address.

Base Url is : https://195.168.2.68:8092/Mobile/

Whats going wrong here?

ρяσѕρєя K
  • 132,198
  • 53
  • 198
  • 213
Sewmi Jans
  • 31
  • 2

1 Answers1

0

Hostname 195.168.2.68 not verified

and

I tried with various Values for CN , I used ip also. now cn values is 'test'.

Since 195.168.2.68 does not match test it all works as expected as CommonName is what is mainly being used for matching, so you need either properly issued certificate or you may i.e. delegate test domain to point to 195.168.2.68 and use test instead of IP to make it match CN. But I'd fix the certificate in first place.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141