当前位置: 首页>>代码示例>>Java>>正文


Java PemTrustOptions类代码示例

本文整理汇总了Java中io.vertx.core.net.PemTrustOptions的典型用法代码示例。如果您正苦于以下问题:Java PemTrustOptions类的具体用法?Java PemTrustOptions怎么用?Java PemTrustOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PemTrustOptions类属于io.vertx.core.net包,在下文中一共展示了PemTrustOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parse

import io.vertx.core.net.PemTrustOptions; //导入依赖的package包/类
@Override
public Handler<ClientOptionsBase> parse(
        final JsonObject options) {
    return Fn.get(() -> {
        final PemTrustOptions pem = Fn.getSemi(
                !options.containsKey(PATH_CERT), LOGGER,
                Trust.CLIENT_PEM,
                () -> new PemTrustOptions().addCertPath(PATH_CERT)
        );
        return option -> option
                .setSsl(true)
                .setUseAlpn(true)
                .setPemTrustOptions(pem)
                .setOpenSslEngineOptions(new OpenSSLEngineOptions());
    }, options);
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:17,代码来源:PemTrust.java

示例2: ex10

import io.vertx.core.net.PemTrustOptions; //导入依赖的package包/类
public void ex10(Vertx vertx) {

    PgConnectOptions options = new PgConnectOptions()
      .setPort(5432)
      .setHost("the-host")
      .setDatabase("the-db")
      .setUsername("user")
      .setPassword("secret")
      .setSsl(true)
      .setPemTrustOptions(new PemTrustOptions().addCertPath("/path/to/cert.pem"));

    PgClient.connect(vertx, options, res -> {
      if (res.succeeded()) {
        // Connected with SSL
      } else {
        System.out.println("Could not connect " + res.cause());
      }
    });
  }
 
开发者ID:vietj,项目名称:reactive-pg-client,代码行数:20,代码来源:Examples.java

示例3: testTLS

import io.vertx.core.net.PemTrustOptions; //导入依赖的package包/类
@Test
public void testTLS(TestContext ctx) {
  Async async = ctx.async();
  PgConnectOptions options = new PgConnectOptions(PgTestBase.options)
    .setSsl(true)
    .setPemTrustOptions(new PemTrustOptions().addCertPath("tls/server.crt"));
  PgClient.connect(vertx, new PgConnectOptions(options).setSsl(true).setTrustAll(true), ctx.asyncAssertSuccess(conn -> {
    ctx.assertTrue(conn.isSSL());
    conn.query("SELECT * FROM Fortune WHERE id=1", ctx.asyncAssertSuccess(result -> {
      ctx.assertEquals(1, result.size());
      Tuple row = result.iterator().next();
      ctx.assertEquals(1, row.getInteger(0));
      ctx.assertEquals("fortune: No such file or directory", row.getString(1));
      async.complete();
    }));
  }));
}
 
开发者ID:vietj,项目名称:reactive-pg-client,代码行数:18,代码来源:TLSTest.java

示例4: setGrpcSslOptions

import io.vertx.core.net.PemTrustOptions; //导入依赖的package包/类
private void setGrpcSslOptions(TCPSSLOptions sslOptions) {
    PemTrustOptions pemTrustOptions = new PemTrustOptions();
    this.config.getSslTrustCerts()
            .forEach(trustKey -> pemTrustOptions.addCertValue(Buffer.buffer(trustKey)));
    sslOptions
            .setSsl(true)
            .setUseAlpn(true)
            .setPemTrustOptions(pemTrustOptions);
    final String sslCert = this.config.getSslCert();
    final String sslKey = this.config.getSslKey();
    if (sslKey != null && sslCert != null) {
        PemKeyCertOptions pemKeyCertOptions = new PemKeyCertOptions()
                .setKeyValue(Buffer.buffer(sslKey))
                .setCertValue(Buffer.buffer(sslCert));
        sslOptions.setPemKeyCertOptions(pemKeyCertOptions);
    }
}
 
开发者ID:Deutsche-Boerse-Risk,项目名称:DAVe,代码行数:18,代码来源:GrpcPersistenceService.java

示例5: setSsl

import io.vertx.core.net.PemTrustOptions; //导入依赖的package包/类
private void setSsl(HttpServerOptions httpServerOptions) {
    ApiConfig.SslConfig sslConfig = config.getSsl();
    if (!sslConfig.isEnable()) {
        return;
    }
    httpServerOptions.setSsl(true);
    PemKeyCertOptions pemKeyCertOptions = new PemKeyCertOptions()
            .setKeyValue(Buffer.buffer(sslConfig.getSslKey()))
            .setCertValue(Buffer.buffer(sslConfig.getSslCert()));
    httpServerOptions.setPemKeyCertOptions(pemKeyCertOptions);

    PemTrustOptions pemTrustOptions = new PemTrustOptions();
    Arrays.stream(sslConfig.getSslTrustCerts())
            .map(Object::toString)
            .forEach(trustKey -> pemTrustOptions.addCertValue(Buffer.buffer(trustKey)));
    if (!pemTrustOptions.getCertValues().isEmpty()) {
        httpServerOptions.setPemTrustOptions(pemTrustOptions);
        ClientAuth clientAuth = sslConfig.isSslRequireClientAuth() ?
                ClientAuth.REQUIRED : ClientAuth.REQUEST;
        httpServerOptions.setClientAuth(clientAuth);
    }
}
 
开发者ID:Deutsche-Boerse-Risk,项目名称:DAVe,代码行数:23,代码来源:ApiVerticle.java

示例6: testLoginByCert_usingPemConfig

import io.vertx.core.net.PemTrustOptions; //导入依赖的package包/类
/**
 * Tests authentication with the cert auth backend using PEM file
 */
@Test
public void testLoginByCert_usingPemConfig(TestContext tc) throws VaultException {
  JsonObject config = new JsonObject();
  config.put("host", process.getHost());
  config.put("port", process.getPort());
  config.put("ssl", true);
  PemKeyCertOptions options = new PemKeyCertOptions()
    .addCertPath("target/vault/config/ssl/client-cert.pem")
    .addKeyPath("target/vault/config/ssl/client-privatekey.pem");
  config.put("pemKeyCertOptions", options.toJson());

  PemTrustOptions trust = new PemTrustOptions()
    .addCertPath("target/vault/config/ssl/cert.pem");
  config.put("pemTrustStoreOptions", trust.toJson());

  JksOptions jks = new JksOptions()
    .setPath("target/vault/config/ssl/truststore.jks");
  config.put("trustStoreOptions", jks.toJson());

  client = new SlimVaultClient(vertx, config);

  checkWeCanLoginAndAccessRestrictedSecrets(tc);
}
 
开发者ID:vert-x3,项目名称:vertx-config,代码行数:27,代码来源:VaultClientWithCertTest.java

示例7: getRetrieverConfiguration

import io.vertx.core.net.PemTrustOptions; //导入依赖的package包/类
@Override
protected JsonObject getRetrieverConfiguration() {

  JsonObject config = new JsonObject();
  config.put("host", process.getHost());
  config.put("port", process.getPort());
  config.put("ssl", true);
  PemKeyCertOptions options = new PemKeyCertOptions()
    .addCertPath("target/vault/config/ssl/client-cert.pem")
    .addKeyPath("target/vault/config/ssl/client-privatekey.pem");
  config.put("pemKeyCertOptions", options.toJson());

  PemTrustOptions trust = new PemTrustOptions()
    .addCertPath("target/vault/config/ssl/cert.pem");
  config.put("pemTrustStoreOptions", trust.toJson());

  JksOptions jks = new JksOptions()
    .setPath("target/vault/config/ssl/truststore.jks");
  config.put("trustStoreOptions", jks.toJson());

  config.put("auth-backend", "cert");

  return config;
}
 
开发者ID:vert-x3,项目名称:vertx-config,代码行数:25,代码来源:VaultConfigStoreWithCertsTest.java

示例8: createClientOptions

import io.vertx.core.net.PemTrustOptions; //导入依赖的package包/类
/**
 * Create an options instance for the ProtonClient
 *
 * @return  ProtonClient options instance
 */
private ProtonClientOptions createClientOptions() {

    ProtonClientOptions options = new ProtonClientOptions();
    options.setConnectTimeout(5000);
    options.setReconnectAttempts(-1).setReconnectInterval(1000); // reconnect forever, every 1000 millisecs

    if (certDir != null) {
        options.setSsl(true)
                .addEnabledSaslMechanism("EXTERNAL")
                .setHostnameVerificationAlgorithm("")
                .setPemTrustOptions(new PemTrustOptions()
                        .addCertPath(new File(certDir, "ca.crt").getAbsolutePath()))
                .setPemKeyCertOptions(new PemKeyCertOptions()
                        .addCertPath(new File(certDir, "tls.crt").getAbsolutePath())
                        .addKeyPath(new File(certDir, "tls.key").getAbsolutePath()));
    }
    return options;
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:24,代码来源:MqttLwt.java

示例9: createClientOptions

import io.vertx.core.net.PemTrustOptions; //导入依赖的package包/类
/**
 * Create an options instance for the ProtonClient
 *
 * @return		ProtonClient options instance
 */
private ProtonClientOptions createClientOptions() {

	ProtonClientOptions options = new ProtonClientOptions();
	options.setConnectTimeout(1000);
	options.setReconnectAttempts(-1).setReconnectInterval(1000); // reconnect forever, every 1000 millisecs

	if (this.bridgeConfigProperties.getEndpointConfigProperties().getCertDir() != null && this.bridgeConfigProperties.getEndpointConfigProperties().getCertDir().length() > 0) {
		String certDir = this.bridgeConfigProperties.getEndpointConfigProperties().getCertDir();
		log.info("Enabling SSL configuration for AMQP with TLS certificates from {}", certDir);
		options.setSsl(true)
				.addEnabledSaslMechanism("EXTERNAL")
				.setHostnameVerificationAlgorithm("")
				.setPemTrustOptions(new PemTrustOptions()
						.addCertPath(new File(certDir, "ca.crt").getAbsolutePath()))
				.setPemKeyCertOptions(new PemKeyCertOptions()
						.addCertPath(new File(certDir, "tls.crt").getAbsolutePath())
						.addKeyPath(new File(certDir, "tls.key").getAbsolutePath()));
	}

	return options;
}
 
开发者ID:strimzi,项目名称:amqp-kafka-bridge,代码行数:27,代码来源:AmqpBridge.java

示例10: connect

import io.vertx.core.net.PemTrustOptions; //导入依赖的package包/类
@Override
public void connect(String username, String password, Handler<AsyncResult<Client>> connectHandler) {

    MqttClientOptions options =
            new MqttClientOptions()
            .setUsername(username)
            .setPassword(password);

    if (this.serverCert != null && !this.serverCert.isEmpty()) {
        options.setSsl(true)
                .setHostnameVerificationAlgorithm("")
                .setPemTrustOptions(new PemTrustOptions().addCertPath(this.serverCert));
    }

    this.client = io.vertx.mqtt.MqttClient.create(vertx, options);
    this.client.connect(this.port, this.hostname, done -> {

        if (done.succeeded()) {

            log.info("Connected to {}:{}", this.hostname, this.port);

            this.client.publishHandler(m -> {

                MessageDelivery messageDelivery = new MessageDelivery(m.topicName(), m.payload().getBytes());
                this.receivedHandler.handle(messageDelivery);
            });

            this.client.subscribeCompletionHandler(suback -> {
                log.info("Subscription [{}], granted QoS levels {}", suback.messageId(), suback.grantedQoSLevels());
            });

            connectHandler.handle(Future.succeededFuture(this));

        } else {

            log.error("Error connecting to the service", done.cause());
            connectHandler.handle(Future.failedFuture(done.cause()));
        }
    });
}
 
开发者ID:EnMasseProject,项目名称:enmasse-workshop,代码行数:41,代码来源:MqttClient.java

示例11: getTrustOptions

import io.vertx.core.net.PemTrustOptions; //导入依赖的package包/类
/**
 * Gets the trust options derived from the trust store properties.
 * 
 * @return The trust options or {@code null} if trust store path is not set or not supported.
 */
public final TrustOptions getTrustOptions() {

    if (trustStorePath == null) {
        return null;
    }

    final FileFormat format = FileFormat.orDetect(trustStoreFormat, trustStorePath);

    if (format == null) {
        LOG.debug("unsupported trust store format");
        return null;
    }

    switch (format) {
    case PEM:
        LOG.debug("using certificates from file [{}] as trust anchor", trustStorePath);
        return new PemTrustOptions().addCertPath(trustStorePath);
    case PKCS12:
        LOG.debug("using certificates from PKCS12 key store [{}] as trust anchor", trustStorePath);
        return new PfxOptions()
                .setPath(getTrustStorePath())
                .setPassword(getTrustStorePassword());
    case JKS:
        LOG.debug("using certificates from JKS key store [{}] as trust anchor", trustStorePath);
        return new JksOptions()
                .setPath(getTrustStorePath())
                .setPassword(getTrustStorePassword());
    default:
        LOG.debug("unsupported trust store format: {}", format);
        return null;
    }
}
 
开发者ID:eclipse,项目名称:hono,代码行数:38,代码来源:AbstractConfig.java

示例12: exampleWithCerts

import io.vertx.core.net.PemTrustOptions; //导入依赖的package包/类
public void exampleWithCerts(Vertx vertx) {
  JsonObject vault_config = new JsonObject();

  // ...

  PemKeyCertOptions certs = new PemKeyCertOptions()
    .addCertPath("target/vault/config/ssl/client-cert.pem")
    .addKeyPath("target/vault/config/ssl/client-privatekey.pem");
  vault_config.put("pemKeyCertOptions", certs.toJson());

  PemTrustOptions trust = new PemTrustOptions()
    .addCertPath("target/vault/config/ssl/cert.pem");
  vault_config.put("pemTrustStoreOptions", trust.toJson());

  JksOptions jks = new JksOptions()
    .setPath("target/vault/config/ssl/truststore.jks");
  vault_config.put("trustStoreOptions", jks.toJson());

  vault_config.put("auth-backend", "cert");

  // Path to the secret to read.
  vault_config.put("path", "secret/my-secret");

  ConfigStoreOptions store = new ConfigStoreOptions()
    .setType("vault")
    .setConfig(vault_config);

  ConfigRetriever retriever = ConfigRetriever.create(vertx,
    new ConfigRetrieverOptions().addStore(store));
}
 
开发者ID:vert-x3,项目名称:vertx-config,代码行数:31,代码来源:Examples.java

示例13: createClientOptions

import io.vertx.core.net.PemTrustOptions; //导入依赖的package包/类
private static ProtonClientOptions createClientOptions(String certDir)
{
    ProtonClientOptions options = new ProtonClientOptions();

    if (certDir != null) {
        options.setSsl(true)
                .setHostnameVerificationAlgorithm("")
                .setPemTrustOptions(new PemTrustOptions()
                        .addCertPath(new File(certDir, "ca.crt").getAbsolutePath()))
                .setPemKeyCertOptions(new PemKeyCertOptions()
                        .setCertPath(new File(certDir, "tls.crt").getAbsolutePath())
                        .setKeyPath(new File(certDir, "tls.key").getAbsolutePath()));
    }
    return options;
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:16,代码来源:Main.java

示例14: getOptions

import io.vertx.core.net.PemTrustOptions; //导入依赖的package包/类
private ProtonClientOptions getOptions() {
    ProtonClientOptions options = new ProtonClientOptions();
    if (certDir != null) {
        options.setHostnameVerificationAlgorithm("")
                .setSsl(true)
                .addEnabledSaslMechanism("EXTERNAL")
                .setHostnameVerificationAlgorithm("")
                .setPemTrustOptions(new PemTrustOptions()
                        .addCertPath(new File(certDir, "ca.crt").getAbsolutePath()))
                .setPemKeyCertOptions(new PemKeyCertOptions()
                        .setCertPath(new File(certDir, "tls.crt").getAbsolutePath())
                        .setKeyPath(new File(certDir, "tls.key").getAbsolutePath()));
    }
    return options;
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:16,代码来源:Forwarder.java

示例15: createOptionsForTls

import io.vertx.core.net.PemTrustOptions; //导入依赖的package包/类
private static ProtonServerOptions createOptionsForTls(final String certDir) {
    ProtonServerOptions options = new ProtonServerOptions();
    PemKeyCertOptions pemKeyCertOptions = new PemKeyCertOptions();
    pemKeyCertOptions.setCertPath(certDir + File.separator + "tls.crt");
    pemKeyCertOptions.setKeyPath(certDir + File.separator + "tls.key");
    options.setPemKeyCertOptions(pemKeyCertOptions);
    options.setClientAuth(ClientAuth.REQUIRED);
    options.setSsl(true);
    PemTrustOptions pemTrustOptions = new PemTrustOptions();
    pemTrustOptions.addCertPath(certDir + File.separator + "ca.crt");
    options.setPemTrustOptions(pemTrustOptions);
    return options;
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:14,代码来源:Main.java


注:本文中的io.vertx.core.net.PemTrustOptions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。