mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-02-08 23:39:38 +03:00
[FEATURE] Fix truststore path
This commit is contained in:
parent
1d63fbbd93
commit
907332ff06
2 changed files with 7 additions and 1 deletions
|
@ -63,7 +63,7 @@ public static void main(String[] args) throws Exception {
|
||||||
directories.collect();
|
directories.collect();
|
||||||
CertificateManager certificateManager = new CertificateManager();
|
CertificateManager certificateManager = new CertificateManager();
|
||||||
try {
|
try {
|
||||||
certificateManager.readTrustStore(dir.resolve("truststore"));
|
certificateManager.readTrustStore(directories.trustStore);
|
||||||
} catch (CertificateException e) {
|
} catch (CertificateException e) {
|
||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
public class CertificateManager {
|
public class CertificateManager {
|
||||||
private transient final Logger logger = LogManager.getLogger();
|
private transient final Logger logger = LogManager.getLogger();
|
||||||
public LauncherTrustManager trustManager;
|
public LauncherTrustManager trustManager;
|
||||||
|
private Path truststorePath;
|
||||||
|
|
||||||
public void writePrivateKey(Path file, PrivateKey privateKey) throws IOException {
|
public void writePrivateKey(Path file, PrivateKey privateKey) throws IOException {
|
||||||
writePrivateKey(IOHelper.newWriter(file), privateKey);
|
writePrivateKey(IOHelper.newWriter(file), privateKey);
|
||||||
|
@ -91,6 +92,7 @@ public X509CertificateHolder readCertificate(Reader reader) throws IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readTrustStore(Path dir) throws IOException, CertificateException {
|
public void readTrustStore(Path dir) throws IOException, CertificateException {
|
||||||
|
this.truststorePath = dir;
|
||||||
if (!IOHelper.isDir(dir)) {
|
if (!IOHelper.isDir(dir)) {
|
||||||
Files.createDirectories(dir);
|
Files.createDirectories(dir);
|
||||||
try {
|
try {
|
||||||
|
@ -131,4 +133,8 @@ public LauncherTrustManager.CheckClassResult checkClass(Class<?> clazz) {
|
||||||
X509Certificate[] certificates = JVMHelper.getCertificates(clazz);
|
X509Certificate[] certificates = JVMHelper.getCertificates(clazz);
|
||||||
return trustManager.checkCertificates(certificates, trustManager::stdCertificateChecker);
|
return trustManager.checkCertificates(certificates, trustManager::stdCertificateChecker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Path getTruststorePath() {
|
||||||
|
return truststorePath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue