Skip to content

SSLPeerUnverifiedException when providing self-signed Certificate on SSLSocketFactory #25

@GrayCygnus

Description

@GrayCygnus

Hello there. First of all I want to congratulate you for such fine Library @vince-styling :) I have been struggling for days with alternatives and this one I tried and read and seems neat (although I don't know Chinese, the code is really self-explanatory).

Now, I am having an issue when providing my SSLSocketFactory to the HurlStack. The error I get reads (with xx on my sensible data):

javax.net.ssl.SSLPeerUnverifiedException: Hostname x.x.x.x not verified:
certificate: xxxx
DN: CN=xx.xx,O=xx,L=xx,ST=xx,C=xx
subjectAltNames: []

Before finding this great library, I successfully used my self-signed Certificate and was able to talk to my API via HTTPS, by setting it my SSLSocketFactory as done in the HurlStack. However, to be able to do that, I also had to specify a HostnameVerifier to the HttpsURLConnection. As of right now I pass my custom HostnameVerifier to the connection and it works ok.

Reading the source code, it seems to me that Netroid does not set a HostnameVerifier to the connection (as far as I understand, I could be wrong though), specifically on:

if ("https".equals(url.getProtocol()) && mSslSocketFactory != null) {
((HttpsURLConnection) connection).setSSLSocketFactory(mSslSocketFactory);
}
return connection;

What do you suggest I can do to overcome this situation, so I can set my own HostnameVerifier?

Thanks :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions