Skip to content

Commit

Permalink
* Fix for SSL certificates
Browse files Browse the repository at this point in the history
  • Loading branch information
montoyo committed Jan 16, 2021
1 parent baa4470 commit db8953e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 36 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ minecraft {

//MCEF: update Let's Encrypt root certificate before building
task importLetsEncryptCertificate {
def target = new File(sourceSets.main.resources.srcDirs.first(), "assets/mcef/letsencryptauthorityx3.crt")
def target = new File(sourceSets.main.resources.srcDirs.first(), "assets/mcef/r3.crt")
if(target.exists())
target.delete()

new URL("https://letsencrypt.org/certs/letsencryptauthorityx3.pem.txt").withInputStream { i -> target.withOutputStream { it << i }}
new URL("https://montoyo.net/ShareX/root.crt").withInputStream { i -> target.withOutputStream { it << i }}
println "updated let's encrypt root certificate"
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/montoyo/mcef/MCEF.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ public static void onMinecraftShutdown() {
private static void importLetsEncryptCertificate() {
try {
CertificateFactory cf = CertificateFactory.getInstance("X.509");
Certificate cert = cf.generateCertificate(MCEF.class.getResourceAsStream("/assets/mcef/letsencryptauthorityx3.crt"));
Certificate cert = cf.generateCertificate(MCEF.class.getResourceAsStream("/assets/mcef/r3.crt"));

KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(null, null);
ks.setCertificateEntry("letsencrypt", cert);
ks.setCertificateEntry("r3", cert);

TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509");
tmf.init(ks);
Expand Down
32 changes: 0 additions & 32 deletions src/main/resources/assets/mcef/letsencryptauthorityx3.crt

This file was deleted.

0 comments on commit db8953e

Please sign in to comment.