use of tech.pegasys.web3signer.core.config.TlsOptions in project web3signer by ConsenSys.
the class CmdLineParamsConfigFileImpl method createServerTlsArgs.
private String createServerTlsArgs() {
final StringBuilder yamlConfig = new StringBuilder();
if (signerConfig.getServerTlsOptions().isPresent()) {
final TlsOptions serverTlsOptions = signerConfig.getServerTlsOptions().get();
yamlConfig.append(String.format(YAML_STRING_FMT, "tls-keystore-file", serverTlsOptions.getKeyStoreFile().toString()));
yamlConfig.append(String.format(YAML_STRING_FMT, "tls-keystore-password-file", serverTlsOptions.getKeyStorePasswordFile().toString()));
if (serverTlsOptions.getClientAuthConstraints().isEmpty()) {
yamlConfig.append(String.format(YAML_BOOLEAN_FMT, "tls-allow-any-client", Boolean.TRUE));
} else {
final ClientAuthConstraints constraints = serverTlsOptions.getClientAuthConstraints().get();
if (constraints.getKnownClientsFile().isPresent()) {
yamlConfig.append(String.format(YAML_STRING_FMT, "tls-known-clients-file", constraints.getKnownClientsFile().get().toString()));
}
if (constraints.isCaAuthorizedClientAllowed()) {
yamlConfig.append(String.format(YAML_BOOLEAN_FMT, "tls-allow-ca-clients", Boolean.TRUE));
}
}
}
return yamlConfig.toString();
}
use of tech.pegasys.web3signer.core.config.TlsOptions in project web3signer by ConsenSys.
the class CmdLineParamsDefaultImpl method createServerTlsArgs.
private Collection<? extends String> createServerTlsArgs() {
final List<String> params = Lists.newArrayList();
if (signerConfig.getServerTlsOptions().isPresent()) {
final TlsOptions serverTlsOptions = signerConfig.getServerTlsOptions().get();
params.add("--tls-keystore-file");
params.add(serverTlsOptions.getKeyStoreFile().toString());
params.add("--tls-keystore-password-file");
params.add(serverTlsOptions.getKeyStorePasswordFile().toString());
if (serverTlsOptions.getClientAuthConstraints().isEmpty()) {
params.add("--tls-allow-any-client=true");
} else {
final ClientAuthConstraints constraints = serverTlsOptions.getClientAuthConstraints().get();
if (constraints.getKnownClientsFile().isPresent()) {
params.add("--tls-known-clients-file");
params.add(constraints.getKnownClientsFile().get().toString());
}
if (constraints.isCaAuthorizedClientAllowed()) {
params.add("--tls-allow-ca-clients=true");
}
}
}
return params;
}
use of tech.pegasys.web3signer.core.config.TlsOptions 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);
}
use of tech.pegasys.web3signer.core.config.TlsOptions in project web3signer by ConsenSys.
the class Runner method applyConfigTlsSettingsTo.
private HttpServerOptions applyConfigTlsSettingsTo(final HttpServerOptions input) {
if (config.getTlsOptions().isEmpty()) {
return input;
}
HttpServerOptions result = new HttpServerOptions(input);
result.setSsl(true);
final TlsOptions tlsConfig = config.getTlsOptions().get();
result = applyTlsKeyStore(result, tlsConfig);
if (tlsConfig.getClientAuthConstraints().isPresent()) {
result = applyClientAuthentication(result, tlsConfig.getClientAuthConstraints().get());
}
return result;
}
use of tech.pegasys.web3signer.core.config.TlsOptions in project web3signer by ConsenSys.
the class ServerSideTlsAcceptanceTest method createTlsSigner.
private Signer createTlsSigner(final TlsCertificateDefinition serverPresentedCerts, final TlsCertificateDefinition clientExpectedCert, final TlsCertificateDefinition clientCertInServerWhitelist, final TlsCertificateDefinition clientToPresent, final int fixedListenPort, final boolean useConfigFile) {
try {
final SignerConfigurationBuilder configBuilder = new SignerConfigurationBuilder().withHttpPort(fixedListenPort).withUseConfigFile(useConfigFile).withMode("eth1");
final ClientAuthConstraints clientAuthConstraints;
if (clientCertInServerWhitelist != null) {
final Path fingerPrintFilePath = dataPath.resolve("known_clients");
populateFingerprintFile(fingerPrintFilePath, clientCertInServerWhitelist, Optional.empty());
clientAuthConstraints = BasicClientAuthConstraints.fromFile(fingerPrintFilePath.toFile());
} else {
clientAuthConstraints = null;
}
final Path passwordPath = dataPath.resolve("keystore.passwd");
if (serverPresentedCerts.getPassword() != null) {
writeString(passwordPath, serverPresentedCerts.getPassword());
}
final TlsOptions serverOptions = new BasicTlsOptions(serverPresentedCerts.getPkcs12File(), passwordPath.toFile(), Optional.ofNullable(clientAuthConstraints));
configBuilder.withServerTlsOptions(serverOptions);
final ClientTlsConfig clientTlsConfig;
if (clientExpectedCert != null) {
clientTlsConfig = new ClientTlsConfig(clientExpectedCert, clientToPresent);
} else {
clientTlsConfig = null;
}
return new Signer(configBuilder.build(), clientTlsConfig);
} catch (final Exception e) {
fail("Failed to create EthSigner.", e);
return null;
}
}
Aggregations