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:// ?

example:

public class RetrofitRequest {

    private static final String BASE_URL_BY_SSL = "https://example.com/";
    private static final String BASE_URL_WITHOUT_SSL = "http://example.com/";

    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)
                    .build();

            retrofit = new Retrofit.Builder()
                    .baseUrl(BASE_URL)
                    .client(client)
                    .addConverterFactory(GsonConverterFactory.create())
                    .build();
        }
        return retrofit;
    }
}