I'm currently writing a small Android Library which should enable secure communication with a remote JavaEE Server. It will use HttpsURLConnection and will call a specific servlet on the server side (because i only suply the android library i don't know the server side implementation). This communication should be as secure as possible (nothing will ever be 100% secure). Therefore I don't want to fully rely on protocol negotiation between server and client - just hoping they will choose a current TLS Version. If the server doesn't support a secure protocol the connection should not be possible (e.g. I don't want to support SSL3.0 or lower).
I know that i can define a cipher suite by writing an own SSLSocketFactory. But it would also be nice to know which security provider the application will choose (to know if the communication of my app is affected by a provider-specific security issue). It is definitely possible to add a new provider.
But is there also a way to force java to only use a provider xy of my choice (other than bouncy castle or sun)? Maybe a own implemented provider for OpenSSL?
Update: i found the following statement in oracles provider documentation:
"A program may simply request a particular type of object (such as a Signature object) implementing a particular service (such as the DSA signature algorithm) and get an implementation from one of the installed providers. If desired, a program may instead request an implementation from a specific provider."
and the following example:
md = MessageDigest.getInstance("MD5", "ProviderC");
So it is possible to define which provider should be used for MessageDigest. But is there the same option for HttpsURLConnection functionality?
Edit: After even more research I found that in Security it is possible to add a provider at a specific position.
public static int insertProviderAt(myProvider, position)
Will it be sufficient for my purpose to add my own provider at the first position?