Search in sources :

Example 1 with SelfSignedCertificate

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);
    }
}
Also used : SelfSignedCertificate(tech.pegasys.signers.hashicorp.dsl.certificates.SelfSignedCertificate) TomlStringBuilder(tech.pegasys.signers.secp256k1.common.TomlStringBuilder) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 SelfSignedCertificate (tech.pegasys.signers.hashicorp.dsl.certificates.SelfSignedCertificate)1 TomlStringBuilder (tech.pegasys.signers.secp256k1.common.TomlStringBuilder)1