Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow paths of public/private key pair to be customized #504

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions alpine-common/src/main/java/alpine/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ public enum AlpineKey implements Key {
WORKER_THREAD_MULTIPLIER ("alpine.worker.thread.multiplier", 4),
DATA_DIRECTORY ("alpine.data.directory", "~/.alpine"),
SECRET_KEY_PATH ("alpine.secret.key.path", null),
PRIVATE_KEY_PATH ("alpine.private.key.path", null),
PUBLIC_KEY_PATH ("alpine.public.key.path", null),
DATABASE_MODE ("alpine.database.mode", "embedded"),
DATABASE_PORT ("alpine.database.port", 9092),
DATABASE_URL ("alpine.database.url", "jdbc:h2:mem:alpine"),
Expand Down
10 changes: 10 additions & 0 deletions alpine-infra/src/main/java/alpine/security/crypto/KeyManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,16 @@ private File getKeyPath(final KeyType keyType) {
if (secretKeyPath != null) {
return Paths.get(secretKeyPath).toFile();
}
} else if (keyType == KeyType.PRIVATE) {
final String privateKeyPath = Config.getInstance().getProperty(Config.AlpineKey.PRIVATE_KEY_PATH);
if (privateKeyPath != null) {
return Paths.get(privateKeyPath).toFile();
}
} else if (keyType == KeyType.PUBLIC) {
final String publicKeyPath = Config.getInstance().getProperty(Config.AlpineKey.PUBLIC_KEY_PATH);
if (publicKeyPath != null) {
return Paths.get(publicKeyPath).toFile();
}
}
return new File(Config.getInstance().getDataDirectorty()
+ File.separator
Expand Down
7 changes: 7 additions & 0 deletions example/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ alpine.data.directory=~/.alpine-example
# Default is "<alpine.data.directory>/keys/secret.key".
# alpine.secret.key.path=/var/run/secrets/secret.key

# Optional
# Defines the paths to the public-private key pair to be used for signing and verifying digital signatures.
# The keys will be generated upon first startup if they do not exist.
# Defaults are "<alpine.data.directory>/keys/private.key" and "<alpine.data.directory>/keys/public.key".
# alpine.private.key.path=/var/run/secrets/private.key
# alpine.public.key.path=/var/run/secrets/public.key

# Required
# Defines the interval (in seconds) to log general heath information.
# If value equals 0, watchdog logging will be disabled.
Expand Down