use of tech.pegasys.signers.hashicorp.TrustStoreType in project signers by ConsenSys.
the class TomlConfigLoader method loadTlsOptions.
private Optional<TlsOptions> loadTlsOptions(final TomlTable tomlInput) {
final boolean tlsEnabled = tomlInput.getBoolean(PROP_HASHICORP_TLS_ENABLE, () -> true);
final String trustStoreString = tomlInput.getString(PROP_HASHICORP_TLS_TS_TYPE);
final String trustStorePath = tomlInput.getString(PROP_HASHICORP_TLS_TS_PATH);
final String trustStorePassword = tomlInput.getString(PROP_HASHICORP_TLS_TS_PASSWORD);
if (!tlsEnabled) {
return Optional.empty();
}
final TrustStoreType trustStoreType = decodeTrustStoreType(trustStoreString);
if (trustStoreType != null) {
if (trustStorePath == null) {
final String error = String.format("%s must be specified if custom trust store (%s) is specified", PROP_HASHICORP_TLS_TS_PATH, PROP_HASHICORP_TLS_TS_TYPE);
throw new HashicorpException(error);
}
if (trustStoreType.isPasswordRequired() && (trustStorePassword == null)) {
final String error = String.format("%s must be specified if custom trust store (%s) is specified", PROP_HASHICORP_TLS_TS_PASSWORD, trustStoreType.name());
throw new HashicorpException(constructErrorMessage(error));
}
}
return Optional.of(new TlsOptions(Optional.ofNullable(trustStoreType), trustStorePath == null ? null : Path.of(trustStorePath), trustStorePassword));
}
Aggregations