Check for ssl and non ssl retrofit request

I want to send a request to my server , and before sending this request , I want to check if my SSL server is available and if it was via https and otherwise use http.

  • How to check if SSL was corrupted using http:// instead of https:// ?


public class RetrofitRequest {

    private static final String BASE_URL_BY_SSL = "";
    private static final String BASE_URL_WITHOUT_SSL = "";

    private static Retrofit retrofit = null;

    public static Retrofit getClient() {
        if (retrofit == null) {
            OkHttpClient client = new OkHttpClient.Builder()
                    .readTimeout(20, TimeUnit.SECONDS)
                    .connectTimeout(20, TimeUnit.SECONDS)

            retrofit = new Retrofit.Builder()
        return retrofit;