After visiting this question.
I saw a few answers and the best was obviously the answer by so_mv. Now it seems that his answer is now outdated, because I have tried it with all the imports and exact code, but it generates tons of errors. I've looked into the documentation to see if anything has changed in the most recent java, but I can't seem to find what the cause is. I think an updated answer to that question would not only benefit me, but the community as a whole.
Errors:
SecurityCheck.java:28: error: <identifier> expected
sc.init(null, new TrustManager[] { trm }, null);
^
SecurityCheck.java:28: error: illegal start of type
sc.init(null, new TrustManager[] { trm }, null);
^
SecurityCheck.java:28: error: illegal start of type
sc.init(null, new TrustManager[] { trm }, null);
^
SecurityCheck.java:28: error: ')' expected
sc.init(null, new TrustManager[] { trm }, null);
^
SecurityCheck.java:28: error: not a statement
sc.init(null, new TrustManager[] { trm }, null);
^
SecurityCheck.java:28: error: ';' expected
sc.init(null, new TrustManager[] { trm }, null);
^
SecurityCheck.java:28: error: illegal start of type
sc.init(null, new TrustManager[] { trm }, null);
^
SecurityCheck.java:28: error: ';' expected
sc.init(null, new TrustManager[] { trm }, null);
^
SecurityCheck.java:28: error: illegal start of type
sc.init(null, new TrustManager[] { trm }, null);
^
SecurityCheck.java:28: error: <identifier> expected
sc.init(null, new TrustManager[] { trm }, null);
^
SecurityCheck.java:28: error: ';' expected
sc.init(null, new TrustManager[] { trm }, null);
^
SecurityCheck.java:29: error: illegal start of type
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
^
SecurityCheck.java:29: error: <identifier> expected
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
^
SecurityCheck.java:29: error: ';' expected
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
^
SecurityCheck.java:29: error: illegal start of type
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
^
SecurityCheck.java:29: error: <identifier> expected
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
^
SecurityCheck.java:29: error: ';' expected
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());