save dynamically created identity beck to file

This commit is contained in:
Jürg Schulthess 2024-07-10 18:44:08 +02:00
parent f0d4c1e8de
commit 706dc03b3e

View File

@ -39,6 +39,8 @@ import org.qortal.settings.Settings;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.StandardCopyOption; import java.nio.file.StandardCopyOption;
import static java.nio.file.StandardOpenOption.CREATE;
import static java.nio.file.StandardOpenOption.WRITE;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
@ -116,6 +118,13 @@ public class RNSNetwork {
serverIdentity = new Identity(); serverIdentity = new Identity();
log.info("APP_NAME: {}, storage path: {}", APP_NAME, serverIdentityPath); log.info("APP_NAME: {}, storage path: {}", APP_NAME, serverIdentityPath);
log.info("new server identity created dynamically."); log.info("new server identity created dynamically.");
// save it back to file by default for next start (possibly add setting to override)
try {
Files.write(serverIdentityPath, serverIdentity.getPrivateKey(), CREATE, WRITE);
log.info("serverIdentity written back to file");
} catch (IOException e) {
log.error("Error while saving serverIdentity to {}", serverIdentityPath, e);
}
} }
log.debug("Server Identity: {}", serverIdentity.toString()); log.debug("Server Identity: {}", serverIdentity.toString());