Skip to content

Commit

Permalink
Implement CA certificate replacement
Browse files Browse the repository at this point in the history
As seen in a popular optimization mod
  • Loading branch information
ACGaming committed Mar 23, 2024
1 parent 32dc99c commit f1853ed
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
group 'net.jan'
version '1.8.1-SNAPSHOT'
version '1.8.2-SNAPSHOT'
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
import net.jan.moddirector.core.util.WebClient;
import net.jan.moddirector.core.util.WebGetResponse;
import net.minecraftforge.fml.exit.QualifiedExit;
import org.apache.commons.io.FileUtils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -79,6 +78,16 @@ private ModDirector(ModDirectorPlatform platform) {

this.modpackRemoteVersion = null;

try (InputStream is = this.getClass().getResource("/cacerts").openStream()) {
File cacertsCopy = File.createTempFile("cacerts", "");
cacertsCopy.deleteOnExit();
FileUtils.copyInputStreamToFile(is, cacertsCopy);
System.setProperty("javax.net.ssl.trustStore", cacertsCopy.getAbsolutePath());
logger.log(ModDirectorSeverityLevel.WARN, "ModDirector", "CORE", "Successfully replaced CA certificates with updated ones!");
} catch (IOException e) {
logger.log(ModDirectorSeverityLevel.WARN, "ModDirector", "CORE", "Unable to replace CA certificates!");
}

logger.log(ModDirectorSeverityLevel.INFO, "ModDirector", "CORE", "Mod director loaded!");
}

Expand Down
Binary file added mod-director-core/src/main/resources/cacerts
Binary file not shown.

0 comments on commit f1853ed

Please sign in to comment.