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

Add ssl option to RemoteDatabaseConfig #1690

Merged
merged 5 commits into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ static DatabaseConfig convertFrom(Config config, String keyPrefix)
.loginTimeout(config.get(keyPrefix + "." + "loginTimeout", int.class, 30))
.socketTimeout(config.get(keyPrefix + "." + "socketTimeout", int.class, 1800))
.ssl(config.get(keyPrefix + "." + "ssl", boolean.class, false))
.sslfactory(config.get(keyPrefix + "." + "sslfactory", String.class, "org.postgresql.ssl.NonValidatingFactory"))
.sslmode(config.getOptional(keyPrefix + "." + "sslmode", String.class))
.sslcert(config.getOptional(keyPrefix + "." + "sslcert", String.class))
.sslkey(config.getOptional(keyPrefix + "." + "sslkey", String.class))
.sslrootcert(config.getOptional(keyPrefix + "." + "sslrootcert", String.class))
.build()));
break;
default:
Expand Down Expand Up @@ -169,6 +174,11 @@ static Config toConfig(DatabaseConfig databaseConfig, ConfigFactory cf, String k
config.set(keyPrefix + "." + "loginTimeout", remoteDatabaseConfig.getLoginTimeout());
config.set(keyPrefix + "." + "socketTimeout", remoteDatabaseConfig.getSocketTimeout());
config.set(keyPrefix + "." + "ssl", remoteDatabaseConfig.getSsl());
config.set(keyPrefix + "." + "sslfactory", remoteDatabaseConfig.getSslfactory());
config.setOptional(keyPrefix + "." + "sslmode", remoteDatabaseConfig.getSslmode());
config.setOptional(keyPrefix + "." + "sslcert", remoteDatabaseConfig.getSslcert());
config.setOptional(keyPrefix + "." + "sslkey", remoteDatabaseConfig.getSslkey());
config.setOptional(keyPrefix + "." + "sslrootcert", remoteDatabaseConfig.getSslrootcert());
break;
default:
throw new AssertionError("Unknown database.type: " + databaseConfig.getType());
Expand Down Expand Up @@ -268,7 +278,19 @@ static Properties buildJdbcProperties(DatabaseConfig config)
props.setProperty("password", rc.get().getPassword());
if (rc.get().getSsl()) {
props.setProperty("ssl", "true");
props.setProperty("sslfactory", "org.postgresql.ssl.NonValidatingFactory"); // disable server certificate validation
props.setProperty("sslfactory", rc.get().getSslfactory());
if (rc.get().getSslmode().isPresent()) {
props.setProperty("sslmode", rc.get().getSslmode().get());
}
if (rc.get().getSslcert().isPresent()) {
props.setProperty("sslcert", rc.get().getSslcert().get());
}
if (rc.get().getSslkey().isPresent()) {
props.setProperty("sslkey", rc.get().getSslkey().get());
}
if (rc.get().getSslrootcert().isPresent()) {
props.setProperty("sslrootcert", rc.get().getSslrootcert().get());
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ public interface RemoteDatabaseConfig

boolean getSsl();

String getSslfactory();

Optional<String> getSslmode();

Optional<String> getSslcert();

Optional<String> getSslkey();

Optional<String> getSslrootcert();

String getDatabase();

static ImmutableRemoteDatabaseConfig.Builder builder()
Expand Down
5 changes: 5 additions & 0 deletions digdag-docs/src/command_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,11 @@ In the config file, following parameters are available
* database.loginTimeout (seconds in integer, default: 30)
* database.socketTimeout (seconds in integer, default: 1800)
* database.ssl (boolean, default: false)
* database.sslfactory (string, default: org.postgresql.ssl.NonValidatingFactory)
* database.sslmode (string)
yoyama marked this conversation as resolved.
Show resolved Hide resolved
* database.sslcert (string)
yoyama marked this conversation as resolved.
Show resolved Hide resolved
* database.sslkey (string)
* database.sslrootcert (string)
yoyama marked this conversation as resolved.
Show resolved Hide resolved
* database.connectionTimeout (seconds in integer, default: 30)
* database.idleTimeout (seconds in integer, default: 600)
* database.validationTimeout (seconds in integer, default: 5)
Expand Down