I developed an Android app that need to connect to a server for Rest request.
I'm new in https and (despite last 2 days spent to looking for on the on web) I've not understood nothing.
The server has a certificate made with COMODO(or geotrust) and has a KeyStore (NOT made by me).
I tried to use:
- Trusting all certificates using HttpClient over HTTPS (bue cannot able to understand where/how use openssl)
- Java HttpsURLConnection and TLS 1.2 (but didin't work)
- Android java.security.cert.CertPathValidatorException: Trust anchor for certification path not found (tried this too but neither works.)
Then I tried this. Trusting all certificates using HttpClient over HTTPS
And works. The problem is that I need to make it specific fpor the access of the server and none else.
This is my code for GET/DELETE request:
public static HttpsURLConnection setHttpsURLConnection(String type, URL url, Activity activity) throws IOException {
trustEveryone(); //from the link above
HttpsURLConnection response=(HttpsURLConnection) url.openConnection();
response.setConnectTimeout(Costanti.connectionTimeout);
response.setReadTimeout(Costanti.connectionTimeout);
response.setRequestProperty("Content-type", "application/json");
response.setRequestProperty("Accept", "application/json");
response.setRequestProperty("Authorization", "Basic tfhtrhsthLkO=");
response.setRequestMethod(type);
return response;
}
I need know what should i do, step by step.
What you need know to help me?
https://www.ssllabs.com/ssltest says:
- TLS 1.2
- TLS 1.1
- TLS 1.0
- Key RSA 2048 bits (e 65537)
- Issuer GeoTrust DV SSL CA - G3
- Signature algorithm SHA256withRSA
- Certificate Transparency Yes (certificate)