delight-im / Android-DDP

[UNMAINTAINED] Meteor's Distributed Data Protocol (DDP) for clients on Android
Apache License 2.0
274 stars 54 forks source link

wss and self signed certificate? #100

Open un-programador opened 8 years ago

un-programador commented 8 years ago

Can I use this framework with a self signed certifcate?

ocram commented 8 years ago

Thanks for your question!

Can you try and see what happens?

I'd expect you'll see a javax.net.ssl.SSLHandshakeException somewhere. From the Android documentation:

This can happen for several reasons, including:

  1. The CA that issued the server certificate was unknown
  2. The server certificate wasn't signed by a CA, but was self signed
  3. The server configuration is missing an intermediate CA [...] In this case, the SSLHandshakeException occurs because you have a CA that isn't trusted by the system. It could be because you have a certificate from a new CA that isn't yet trusted by Android or your app is running on an older version without the CA. More often a CA is unknown because it isn't a public CA, but a private one issued by an organization such as a government, corporation, or education institution for their own use. [...] A TrustManager is what the system uses to validate certificates from the server and—by creating one from a KeyStore with one or more CAs—those will be the only CAs trusted by that TrustManager.

-- https://developer.android.com/training/articles/security-ssl.html#CommonProblems

In TubeSock, which is the WebSocket library that we use, there is an open pull request that adds support for a custom TrustManager: https://github.com/firebase/TubeSock/pull/8

As can be seen, this can be implemented with changes in just a few lines.

Does this help?

musriabhijit commented 7 years ago

com.firebase.tubesock.WebSocketException: error while creating secure socket to wss://tailmaters-dev.meteorapp.com/websocket javax.net.ssl.SSLException: hostname in certificate didn't match: != OR with i am getting this exception and it is happening with api level below 23 and it is working fine with above this version i don't know the exact reason so help me in this

ocram commented 7 years ago

There are some news in https://github.com/delight-im/Android-DDP/issues/101

ocram commented 7 years ago

Now that https://github.com/delight-im/Android-DDP/commit/c4d72267c5c0a9abe7931cc9c4b1255d8c909da9 has arrived, adding support for self-signed certificates should be much simpler.