[FEATURE] Fix truststore path

This commit is contained in:
Gravita 2025-01-27 20:20:27 +07:00
parent 1d63fbbd93
commit 907332ff06
No known key found for this signature in database
GPG key ID: 543A8F335C9CD633
2 changed files with 7 additions and 1 deletions

View file

@ -63,7 +63,7 @@ public static void main(String[] args) throws Exception {
directories.collect();
CertificateManager certificateManager = new CertificateManager();
try {
certificateManager.readTrustStore(dir.resolve("truststore"));
certificateManager.readTrustStore(directories.trustStore);
} catch (CertificateException e) {
throw new IOException(e);
}

View file

@ -29,6 +29,7 @@
public class CertificateManager {
private transient final Logger logger = LogManager.getLogger();
public LauncherTrustManager trustManager;
private Path truststorePath;
public void writePrivateKey(Path file, PrivateKey privateKey) throws IOException {
writePrivateKey(IOHelper.newWriter(file), privateKey);
@ -91,6 +92,7 @@ public X509CertificateHolder readCertificate(Reader reader) throws IOException {
}
public void readTrustStore(Path dir) throws IOException, CertificateException {
this.truststorePath = dir;
if (!IOHelper.isDir(dir)) {
Files.createDirectories(dir);
try {
@ -131,4 +133,8 @@ public LauncherTrustManager.CheckClassResult checkClass(Class<?> clazz) {
X509Certificate[] certificates = JVMHelper.getCertificates(clazz);
return trustManager.checkCertificates(certificates, trustManager::stdCertificateChecker);
}
public Path getTruststorePath() {
return truststorePath;
}
}