Search in sources :

Example 1 with Signer

use of tech.pegasys.web3signer.dsl.signer.Signer in project web3signer by ConsenSys.

the class KeyManagerTestBase method setupSignerWithKeyManagerApi.

protected void setupSignerWithKeyManagerApi(final boolean insertSlashingProtectionData) throws URISyntaxException {
    final SignerConfigurationBuilder builder = new SignerConfigurationBuilder();
    builder.withKeyStoreDirectory(testDirectory).withMode("eth2").withAltairForkEpoch(MINIMAL_ALTAIR_FORK).withSlashingEnabled(true).withSlashingProtectionDbUsername(DB_USERNAME).withSlashingProtectionDbPassword(DB_PASSWORD).withKeyManagerApiEnabled(true);
    startSigner(builder.build());
    if (insertSlashingProtectionData) {
        final SignerConfigurationBuilder importBuilder = new SignerConfigurationBuilder();
        importBuilder.withMode("eth2").withSlashingEnabled(true).withSlashingProtectionDbUrl(signer.getSlashingDbUrl()).withSlashingProtectionDbUsername(DB_USERNAME).withSlashingProtectionDbPassword(DB_PASSWORD).withKeyStoreDirectory(testDirectory).withSlashingImportPath(getResourcePath("slashing/slashingImport_two_entries.json")).withHttpPort(// prevent wait for Ports file in AT
        12345);
        final Signer importSigner = new Signer(importBuilder.build(), null);
        importSigner.start();
        waitFor(() -> assertThat(importSigner.isRunning()).isFalse());
    }
}
Also used : Signer(tech.pegasys.web3signer.dsl.signer.Signer) SignerConfigurationBuilder(tech.pegasys.web3signer.dsl.signer.SignerConfigurationBuilder)

Example 2 with Signer

use of tech.pegasys.web3signer.dsl.signer.Signer in project web3signer by ConsenSys.

the class AzureKeyVaultAcceptanceTest method invalidVaultParametersFailsToStartSigner.

@Test
void invalidVaultParametersFailsToStartSigner() {
    final AzureKeyVaultParameters azureParams = new DefaultAzureKeyVaultParameters("nonExistentVault", CLIENT_ID, TENANT_ID, CLIENT_SECRET);
    final SignerConfigurationBuilder configBuilder = new SignerConfigurationBuilder().withMode("eth2").withAzureKeyVaultParameters(azureParams).withHttpPort(// required to prevent waiting for ports file.
    9000);
    final Signer signer = new Signer(configBuilder.build(), null);
    signer.start();
    waitFor(30, () -> assertThat(signer.isRunning()).isTrue());
    waitFor(30, () -> assertThat(signer.isRunning()).isFalse());
}
Also used : Signer(tech.pegasys.web3signer.dsl.signer.Signer) SignerConfigurationBuilder(tech.pegasys.web3signer.dsl.signer.SignerConfigurationBuilder) AzureKeyVaultParameters(tech.pegasys.web3signer.core.config.AzureKeyVaultParameters) DefaultAzureKeyVaultParameters(tech.pegasys.web3signer.dsl.utils.DefaultAzureKeyVaultParameters) DefaultAzureKeyVaultParameters(tech.pegasys.web3signer.dsl.utils.DefaultAzureKeyVaultParameters) Test(org.junit.jupiter.api.Test)

Example 3 with Signer

use of tech.pegasys.web3signer.dsl.signer.Signer in project web3signer by ConsenSys.

the class DeleteKeystoresAcceptanceTest method deletingDisablesSigningForAllWeb3Signers.

@Test
public void deletingDisablesSigningForAllWeb3Signers() throws URISyntaxException, JsonProcessingException {
    final String firstPubkey = createBlsKey("eth2/bls_keystore.json", "somepassword");
    final String secondPubKey = createBlsKey("eth2/bls_keystore_2.json", "otherpassword");
    setupSignerWithKeyManagerApi(WITH_SLASHING_PROTECTION_DATA);
    final SignerConfiguration signer2Configuration = new SignerConfigurationBuilder().withKeyStoreDirectory(testDirectory).withMode("eth2").withNetwork("minimal").withAltairForkEpoch(MINIMAL_ALTAIR_FORK).withSlashingEnabled(true).withSlashingProtectionDbUrl(signer.getSlashingDbUrl()).withSlashingProtectionDbUsername(DB_USERNAME).withSlashingProtectionDbPassword(DB_PASSWORD).withKeyManagerApiEnabled(true).build();
    final Signer signer2 = new Signer(signer2Configuration, null);
    signer2.start();
    signer2.awaitStartupCompletion();
    callDeleteKeystores(composeRequestBody()).then().contentType(ContentType.JSON).assertThat().statusCode(200).body("data[0].status", is("deleted")).and().body("slashing_protection", is(singleEntrySlashingData));
    callListKeys().then().statusCode(200).contentType(ContentType.JSON).body("data.size()", is(1)).and().body("data[0].validating_pubkey", is(secondPubKey));
    callListKeys(signer2).then().statusCode(200).contentType(ContentType.JSON).body("data.size()", is(2)).and().body("data[0].validating_pubkey", is(firstPubkey)).body("data[1].validating_pubkey", is(secondPubKey));
    final Eth2SigningRequestBody attestationRequest = Eth2RequestUtils.createCannedRequest(ArtifactType.ATTESTATION);
    signer.eth2Sign(firstPubkey, attestationRequest, ContentType.TEXT).then().statusCode(404);
    signer2.eth2Sign(firstPubkey, attestationRequest, ContentType.TEXT).then().statusCode(412);
    final Eth2SigningRequestBody blockRequest = Eth2RequestUtils.createCannedRequest(ArtifactType.BLOCK_V2);
    signer.eth2Sign(firstPubkey, blockRequest, ContentType.TEXT).then().statusCode(404);
    signer2.eth2Sign(firstPubkey, blockRequest, ContentType.TEXT).then().statusCode(412);
}
Also used : Signer(tech.pegasys.web3signer.dsl.signer.Signer) SignerConfigurationBuilder(tech.pegasys.web3signer.dsl.signer.SignerConfigurationBuilder) Eth2SigningRequestBody(tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.Eth2SigningRequestBody) SignerConfiguration(tech.pegasys.web3signer.dsl.signer.SignerConfiguration) Test(org.junit.jupiter.api.Test)

Example 4 with Signer

use of tech.pegasys.web3signer.dsl.signer.Signer in project web3signer by ConsenSys.

the class AzureKeyVaultAcceptanceTest method invalidVaultParametersFailsToStartSigner.

@Test
void invalidVaultParametersFailsToStartSigner() {
    final AzureKeyVaultParameters azureParams = new DefaultAzureKeyVaultParameters("nonExistentVault", CLIENT_ID, TENANT_ID, CLIENT_SECRET);
    final SignerConfigurationBuilder configBuilder = new SignerConfigurationBuilder().withMode("eth2").withAzureKeyVaultParameters(azureParams).withHttpPort(// required to prevent waiting for ports file.
    9000);
    final Signer signer = new Signer(configBuilder.build(), null);
    signer.start();
    waitFor(30, () -> assertThat(signer.isRunning()).isTrue());
    waitFor(30, () -> assertThat(signer.isRunning()).isFalse());
}
Also used : Signer(tech.pegasys.web3signer.dsl.signer.Signer) SignerConfigurationBuilder(tech.pegasys.web3signer.dsl.signer.SignerConfigurationBuilder) AzureKeyVaultParameters(tech.pegasys.web3signer.signing.config.AzureKeyVaultParameters) DefaultAzureKeyVaultParameters(tech.pegasys.web3signer.dsl.utils.DefaultAzureKeyVaultParameters) DefaultAzureKeyVaultParameters(tech.pegasys.web3signer.dsl.utils.DefaultAzureKeyVaultParameters) Test(org.junit.jupiter.api.Test)

Example 5 with Signer

use of tech.pegasys.web3signer.dsl.signer.Signer in project web3signer by ConsenSys.

the class ServerSideTlsCaClientAcceptanceTest method createSigner.

private Signer createSigner(final TlsCertificateDefinition certInCa, final Path testDir, final boolean useConfigFile) throws Exception {
    final Path passwordPath = testDir.resolve("keystore.passwd");
    writeString(passwordPath, serverCert.getPassword());
    final TlsOptions serverOptions = new BasicTlsOptions(serverCert.getPkcs12File(), passwordPath.toFile(), Optional.of(BasicClientAuthConstraints.caOnly()));
    final SignerConfigurationBuilder configBuilder = new SignerConfigurationBuilder().withServerTlsOptions(serverOptions).withOverriddenCA(certInCa).withUseConfigFile(useConfigFile).withMode("eth2");
    final ClientTlsConfig clientTlsConfig = new ClientTlsConfig(serverCert, clientCert);
    return new Signer(configBuilder.build(), clientTlsConfig);
}
Also used : Path(java.nio.file.Path) ClientTlsConfig(tech.pegasys.web3signer.dsl.tls.ClientTlsConfig) Signer(tech.pegasys.web3signer.dsl.signer.Signer) BasicTlsOptions(tech.pegasys.web3signer.dsl.tls.BasicTlsOptions) SignerConfigurationBuilder(tech.pegasys.web3signer.dsl.signer.SignerConfigurationBuilder) BasicTlsOptions(tech.pegasys.web3signer.dsl.tls.BasicTlsOptions) TlsOptions(tech.pegasys.web3signer.core.config.TlsOptions)

Aggregations

Signer (tech.pegasys.web3signer.dsl.signer.Signer)13 SignerConfigurationBuilder (tech.pegasys.web3signer.dsl.signer.SignerConfigurationBuilder)12 Test (org.junit.jupiter.api.Test)7 Path (java.nio.file.Path)5 Jdbi (org.jdbi.v3.core.Jdbi)3 TlsOptions (tech.pegasys.web3signer.core.config.TlsOptions)3 BasicTlsOptions (tech.pegasys.web3signer.dsl.tls.BasicTlsOptions)3 InterchangeV5Format (dsl.InterchangeV5Format)2 SignedArtifacts (dsl.SignedArtifacts)2 Map (java.util.Map)2 Eth2SigningRequestBody (tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.Eth2SigningRequestBody)2 ClientTlsConfig (tech.pegasys.web3signer.dsl.tls.ClientTlsConfig)2 DefaultAzureKeyVaultParameters (tech.pegasys.web3signer.dsl.utils.DefaultAzureKeyVaultParameters)2 SignedAttestation (tech.pegasys.web3signer.slashingprotection.interchange.model.SignedAttestation)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Response (io.restassured.response.Response)1 File (java.io.File)1 IOException (java.io.IOException)1 SSLHandshakeException (javax.net.ssl.SSLHandshakeException)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1