use of tech.pegasys.signers.hashicorp.dsl.certificates.SelfSignedCertificate in project signers by ConsenSys.
the class MultiKeyTomlFileUtil method createHashicorpTomlFileAt.
public static void createHashicorpTomlFileAt(final Path tomlPath, final HashicorpSigningParams hashicorpNode) {
try {
final Optional<SelfSignedCertificate> tlsCert = hashicorpNode.getServerCertificate();
String trustStorePath = null;
if (tlsCert.isPresent()) {
trustStorePath = CertificateHelpers.createFingerprintFile(tomlPath.getParent(), tlsCert.get(), Optional.of(hashicorpNode.getPort())).toString();
}
final String hashicorpSignerToml = HashicorpConfigUtil.createTomlConfig(hashicorpNode.getHost(), hashicorpNode.getPort(), hashicorpNode.getVaultToken(), hashicorpNode.getSecretHttpPath(), hashicorpNode.getSecretName(), 10_000, tlsCert.isPresent(), tlsCert.map(ignored -> "WHITELIST").orElse(null), trustStorePath, null);
final TomlStringBuilder tomlBuilder = new TomlStringBuilder("signing");
tomlBuilder.withQuotedString("type", "hashicorp-signer");
final String toml = tomlBuilder.build() + hashicorpSignerToml;
createTomlFile(tomlPath, toml);
} catch (final Exception e) {
throw new RuntimeException("Failed to construct a valid hashicorp TOML file", e);
}
}
Aggregations