Skip to content
Snippets Groups Projects
Commit 104dec09 authored by Felix Sidokhine's avatar Felix Sidokhine
Browse files

further cleaned up the mess

parent 7d9c9fc8
No related branches found
No related tags found
No related merge requests found
......@@ -2,8 +2,6 @@ package net.jami.jams.server.licensing;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class LicenseServiceTest {
@Test
......
......@@ -17,7 +17,6 @@ import org.apache.http.ssl.SSLContexts;
import javax.net.ssl.SSLContext;
import java.io.InputStream;
import java.security.KeyStore;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.util.HashMap;
import java.util.TimerTask;
......@@ -33,7 +32,6 @@ public class UpdateCheckTask extends TimerTask {
private HashMap<String, FileDescription> localData;
private SSLContext sslContext;
private volatile KeyStore trustStore;
private static final String KEYSTORE_TYPE = "JKS";
protected UpdateCheckTask() {
try {
......
package net.jami.jams.updater;
import lombok.extern.slf4j.Slf4j;
import net.jami.jams.common.utils.X509Utils;
import org.apache.http.ssl.SSLContexts;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import java.io.InputStream;
import java.security.KeyStore;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
@Slf4j
public class UpdateDownloader {
private SSLSocketFactory sslSocketFactory;
private SSLContext sslContext;
private static final String KEYSTORE_TYPE = "JKS";
private KeyStore trustStore;
public UpdateDownloader() {
try {
InputStream is = UpdateCheckTask.class.getClassLoader().getResourceAsStream("oem/ca.crt");
X509Certificate certificate = X509Utils.getCertificateFromPEMString(new String(is.readAllBytes()));
trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
trustStore.load(null, null);
trustStore.setCertificateEntry("ca", certificate);
}
catch (Exception e){
log.info("Could not load SFL's CA - this should not happen! detailed error: {}",e.getMessage());
}
}
//TODO: Download the files and dump them into a tmp folder.
public boolean downloadFiles(){
try {
//We can perpetually reload this,it doesn't really harm anything.
//KeyStore ks = KeyStore.getInstance(KEYSTORE_TYPE);
//ks.load(null);
//ks.setKeyEntry("licenses", JAMSUpdater.privateKey,"".toCharArray(),new Certificate[]{JAMSUpdater.certificate});
//sslContext = SSLContexts.custom().loadKeyMaterial(ks, "".toCharArray()).loadTrustMaterial(trustStore, null)
// .build();
//Build the SSL context here, (this is fairly simple)
KeyStore ks = KeyStore.getInstance(KEYSTORE_TYPE);
ks.load(null);
ks.setKeyEntry("licenses", JAMSUpdater.privateKey,"".toCharArray(),new Certificate[]{JAMSUpdater.certificate});
sslContext = SSLContexts.custom().loadKeyMaterial(ks, "".toCharArray()).loadTrustMaterial(trustStore, null).build();
//Try to download the files and store the to /tmp
//Check file checksums.
//Check file checksums and trigger the update cycle itself - but this is already done in the outer function.
return true;
}
catch (Exception e){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment