use of tech.pegasys.signers.hashicorp.HashicorpConnection in project web3signer by ConsenSys.
the class AbstractArtifactSignerFactory method extractBytesFromVault.
protected Bytes extractBytesFromVault(final HashicorpSigningMetadata metadata) {
final Optional<TlsOptions> tlsOptions = buildTlsOptions(metadata);
try {
final HashicorpConnection connection = hashicorpConnectionFactory.create(new ConnectionParameters(metadata.getServerHost(), Optional.ofNullable(metadata.getServerPort()), tlsOptions, Optional.ofNullable(metadata.getTimeout())));
final String secret = connection.fetchKey(new KeyDefinition(metadata.getKeyPath(), Optional.ofNullable(metadata.getKeyName()), metadata.getToken()));
return Bytes.fromHexString(secret);
} catch (final Exception e) {
throw new SigningMetadataException("Failed to fetch secret from hashicorp vault", e);
}
}
use of tech.pegasys.signers.hashicorp.HashicorpConnection in project web3signer by ConsenSys.
the class AbstractArtifactSignerFactory method extractBytesFromVault.
protected Bytes extractBytesFromVault(final HashicorpSigningMetadata metadata) {
final Optional<TlsOptions> tlsOptions = buildTlsOptions(metadata);
try {
final HashicorpConnection connection = hashicorpConnectionFactory.create(new ConnectionParameters(metadata.getServerHost(), Optional.ofNullable(metadata.getServerPort()), tlsOptions, Optional.ofNullable(metadata.getTimeout())));
final String secret = connection.fetchKey(new KeyDefinition(metadata.getKeyPath(), Optional.ofNullable(metadata.getKeyName()), metadata.getToken()));
return Bytes.fromHexString(secret);
} catch (final Exception e) {
throw new SigningMetadataException("Failed to fetch secret from hashicorp vault", e);
}
}
use of tech.pegasys.signers.hashicorp.HashicorpConnection in project signers by ConsenSys.
the class HashicorpSignerFactory method create.
public Signer create(final HashicorpKeyConfig keyConfig) {
try {
final HashicorpConnectionFactory connectionFactory = new HashicorpConnectionFactory(vertx);
final HashicorpConnection connection = connectionFactory.create(keyConfig.getConnectionParams());
final String secret = connection.fetchKey(keyConfig.getKeyDefinition());
final Credentials credentials = Credentials.create(secret);
return new CredentialSigner(credentials);
} catch (final HashicorpException e) {
throw new SignerInitializationException("Failed to extract secret from Hashicorp vault.", e);
}
}
use of tech.pegasys.signers.hashicorp.HashicorpConnection in project signers by ConsenSys.
the class HashicorpVaultAccessAcceptanceTest method fetchSecretFromVault.
private String fetchSecretFromVault(final Path configFilePath) {
final HashicorpKeyConfig config = TomlConfigLoader.fromToml(configFilePath, null);
final HashicorpConnectionFactory factory = new HashicorpConnectionFactory(vertx);
final HashicorpConnection connection = factory.create(config.getConnectionParams());
return connection.fetchKey(config.getKeyDefinition());
}
Aggregations