Skip to content
Snippets Groups Projects
Commit fc65187f authored by Ludovic Claude's avatar Ludovic Claude
Browse files

Do not use https anymore to connect to workflow

parent 6fb8725a
No related branches found
No related tags found
No related merge requests found
......@@ -10,13 +10,10 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
@RestController
......@@ -44,9 +41,7 @@ public class MiningApi {
private static int sendPost(String url, String query, StringBuilder resp) throws Exception {
URL obj = new URL(url);
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
// TODO: Remove this line for security
allowInsecureConnection(con);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
con.addRequestProperty("Content-Type", "application/json");
......@@ -80,26 +75,4 @@ public class MiningApi {
return respCode;
}
private static void allowInsecureConnection(HttpsURLConnection con) {
TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(
java.security.cert.X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(
java.security.cert.X509Certificate[] certs, String authType) {
}
}
};
try {
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
con.setSSLSocketFactory(sc.getSocketFactory());
} catch (Exception ignored) {
}
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment