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


Java PemKeyCertOptions类代码示例

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


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

示例1: parse

import io.vertx.core.net.PemKeyCertOptions; //导入依赖的package包/类
@Override
public Handler<TCPSSLOptions> parse(final JsonObject options) {
    return Fn.get(() -> {
        final PemKeyCertOptions pem = Fn.getSemi(
                null == options ||
                        !options.containsKey(PATH_KEY) ||
                        !options.containsKey(PATH_CERT), LOGGER,
                Cert.SERVER_PEM,
                () -> new PemKeyCertOptions().setKeyPath(PATH_KEY).setCertPath(PATH_CERT)
        );
        return option -> option
                .setSsl(true)
                .setUseAlpn(true)
                .setPemKeyCertOptions(pem)
                .setOpenSslEngineOptions(new OpenSSLEngineOptions());
    }, options);
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:18,代码来源:PemCert.java

示例2: setGrpcSslOptions

import io.vertx.core.net.PemKeyCertOptions; //导入依赖的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

示例3: setSsl

import io.vertx.core.net.PemKeyCertOptions; //导入依赖的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

示例4: before

import io.vertx.core.net.PemKeyCertOptions; //导入依赖的package包/类
@Before
public void before(TestContext context) {

  PemKeyCertOptions pemKeyCertOptions = new PemKeyCertOptions()
    .setKeyPath("tls/server-key.pem")
    .setCertPath("tls/server-cert.pem");

  MqttServerOptions options = new MqttServerOptions()
    .setPort(MQTT_SERVER_TLS_PORT)
    .setKeyCertOptions(pemKeyCertOptions)
    .setSsl(true);

  // just useful for enabling decryption using Wireshark (which doesn't support default Diffie-Hellmann for key exchange)
  // options.addEnabledCipherSuite("TLS_RSA_WITH_AES_256_CBC_SHA256");

  this.setUp(context, options);
}
 
开发者ID:vert-x3,项目名称:vertx-mqtt,代码行数:18,代码来源:MqttServerSslTest.java

示例5: testLoginByCert_usingPemConfig

import io.vertx.core.net.PemKeyCertOptions; //导入依赖的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

示例6: getRetrieverConfiguration

import io.vertx.core.net.PemKeyCertOptions; //导入依赖的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

示例7: createSecureServer

import io.vertx.core.net.PemKeyCertOptions; //导入依赖的package包/类
private void createSecureServer(VertxRequestHandler requestHandler, Future<Void> startPromise) {
    if (new File(certDir).exists()) {
        HttpServerOptions options = new HttpServerOptions();
        File keyFile = new File(certDir, "tls.key");
        File certFile = new File(certDir, "tls.crt");
        log.info("Loading key from " + keyFile.getAbsolutePath() + ", cert from " + certFile.getAbsolutePath());
        options.setKeyCertOptions(new PemKeyCertOptions()
                .setKeyPath(keyFile.getAbsolutePath())
                .setCertPath(certFile.getAbsolutePath()));
        options.setSsl(true);

        httpsServer = vertx.createHttpServer(options)
                .requestHandler(requestHandler)
                .listen(SECURE_PORT, ar -> {
                    if (ar.succeeded()) {
                        log.info("Started HTTPS server. Listening on port " + SECURE_PORT);
                        startPromise.complete();
                    } else {
                        log.info("Error starting HTTPS server");
                        startPromise.fail(ar.cause());
                    }
                });
    } else {
        startPromise.complete();
    }
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:27,代码来源:HTTPServer.java

示例8: createClientOptions

import io.vertx.core.net.PemKeyCertOptions; //导入依赖的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.PemKeyCertOptions; //导入依赖的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: startTcpServer

import io.vertx.core.net.PemKeyCertOptions; //导入依赖的package包/类
private void startTcpServer(ConfigParser c) {
    int port = c.getPort();
    String keyPath = c.getTlsKeyPath();
    String certPath = c.getTlsCertPath();
    boolean tlsEnabled = c.isTlsEnabled();
    int idleTimeout = c.getSocketIdleTimeout();

    // MQTT over TCP
    NetServerOptions opt = new NetServerOptions()
            .setTcpKeepAlive(true)
            .setIdleTimeout(idleTimeout) // in seconds; 0 means "don't timeout".
            .setPort(port);

    if(tlsEnabled) {
        opt.setSsl(true).setPemKeyCertOptions(new PemKeyCertOptions()
            .setKeyPath(keyPath)
            .setCertPath(certPath)
        );
    }
    NetServer netServer = vertx.createNetServer(opt);
    Map<String, MQTTSession> sessions = new MonitoredMap<>();
    netServer.connectHandler(netSocket -> {
        MQTTNetSocket mqttNetSocket = new MQTTNetSocket(vertx, c, netSocket, sessions);
        mqttNetSocket.start();
    }).listen();
}
 
开发者ID:GruppoFilippetti,项目名称:vertx-mqtt-broker,代码行数:27,代码来源:MQTTBroker.java

示例11: testSslClientAuthentication

import io.vertx.core.net.PemKeyCertOptions; //导入依赖的package包/类
@Test
public void testSslClientAuthentication(TestContext context) {
    JsonObject config = TestConfig.getApiConfig();
    deployApiVerticle(context, config);

    final Async asyncSslClient = context.async();

    HttpClientOptions sslOpts = new HttpClientOptions().setSsl(true)
            .setPemTrustOptions(TestConfig.HTTP_API_CERTIFICATE.trustOptions());

    vertx.createHttpClient(sslOpts).get(port, "localhost", "/api/v1.0/pr/latest", res -> {
        context.assertEquals(200, res.statusCode());
        asyncSslClient.complete();
    }).end();

    final Async asyncSslClientAuth = context.async();
    HttpClientOptions sslClientAuthOpts = new HttpClientOptions().setSsl(true)
            .setPemTrustOptions(TestConfig.HTTP_API_CERTIFICATE.trustOptions())
            .setPemKeyCertOptions(new PemKeyCertOptions()
                    .setKeyPath(TestConfig.HTTP_CLIENT_CERTIFICATE.privateKeyPath())
                    .setCertPath(TestConfig.HTTP_CLIENT_CERTIFICATE.certificatePath()));

    vertx.createHttpClient(sslClientAuthOpts).get(port, "localhost", "/api/v1.0/pr/latest", res -> {
        context.assertEquals(200, res.statusCode());
        asyncSslClientAuth.complete();
    }).end();

    final Async asyncClient = context.async();

    vertx.createHttpClient().get(port, "localhost", "/api/v1.0/pr/latest", res ->
        context.fail("Connected to HTTPS connection with HTTP!")
    ).exceptionHandler(res ->
        asyncClient.complete()
    ).end();
}
 
开发者ID:Deutsche-Boerse-Risk,项目名称:DAVe,代码行数:36,代码来源:ApiVerticleTest.java

示例12: testSslRequiredClientAuthentication

import io.vertx.core.net.PemKeyCertOptions; //导入依赖的package包/类
@Test
public void testSslRequiredClientAuthentication(TestContext context) {
    JsonObject config = TestConfig.getApiConfig();
    config.getJsonObject("ssl").put("sslRequireClientAuth", true);
    deployApiVerticle(context, config);

    final Async asyncSslClient = context.async();

    HttpClientOptions sslOpts = new HttpClientOptions().setSsl(true)
            .setPemTrustOptions(TestConfig.HTTP_API_CERTIFICATE.trustOptions());

    vertx.createHttpClient(sslOpts).get(port, "localhost", "/api/v1.0/pr/latest", res ->
        context.fail("Connected without client authentication!")
    ).exceptionHandler(res ->
        asyncSslClient.complete()
    ).end();

    final Async asyncSslClientAuth = context.async();
    HttpClientOptions sslClientAuthOpts = new HttpClientOptions().setSsl(true)
            .setPemTrustOptions(TestConfig.HTTP_API_CERTIFICATE.trustOptions())
            .setPemKeyCertOptions(new PemKeyCertOptions()
                    .setKeyPath(TestConfig.HTTP_CLIENT_CERTIFICATE.privateKeyPath())
                    .setCertPath(TestConfig.HTTP_CLIENT_CERTIFICATE.certificatePath()));

    vertx.createHttpClient(sslClientAuthOpts).get(port, "localhost", "/api/v1.0/pr/latest", res -> {
        context.assertEquals(200, res.statusCode());
        asyncSslClientAuth.complete();
    }).end();

    final Async asyncClient = context.async();

    vertx.createHttpClient().get(port, "localhost", "/api/v1.0/pr/latest", res ->
        context.fail("Connected to HTTPS connection with HTTP!")
    ).exceptionHandler(res ->
        asyncClient.complete()
    ).end();
}
 
开发者ID:Deutsche-Boerse-Risk,项目名称:DAVe,代码行数:38,代码来源:ApiVerticleTest.java

示例13: testPemConfig

import io.vertx.core.net.PemKeyCertOptions; //导入依赖的package包/类
/**
 * Test a valid PEM configuration.
 */
@Test
public void testPemConfig() {
    final TestConfig cfg = new TestConfig();
    cfg.setKeyPath(PREFIX_KEY_PATH + "hono-messaging-key.pem");
    cfg.setCertPath(PREFIX_KEY_PATH + "hono-messaging-cert.pem");

    final KeyCertOptions options = cfg.getKeyCertOptions();

    Assert.assertNotNull(options);
    Assert.assertThat(options, instanceOf(PemKeyCertOptions.class));
}
 
开发者ID:eclipse,项目名称:hono,代码行数:15,代码来源:AbstractConfigTest.java

示例14: before

import io.vertx.core.net.PemKeyCertOptions; //导入依赖的package包/类
@Before
public void before() {
  PemKeyCertOptions pemKeyCertOptions = new PemKeyCertOptions()
    .setKeyPath("tls/server-key.pem")
    .setCertPath("tls/server-cert.pem");

  MqttServerOptions serverOptions = new MqttServerOptions()
    .setPort(MQTT_SERVER_TLS_PORT)
    .setHost(MQTT_SERVER_HOST)
    .setKeyCertOptions(pemKeyCertOptions)
    .setSsl(true);

  server = MqttServer.create(vertx, serverOptions);

  server.endpointHandler(e -> {
    log.info("Client connected");
    e.disconnectHandler(d -> log.info("Client disconnected"));
    e.accept(false);
  }).listen(ar -> {
    if (ar.succeeded()) {
      log.info("MQTT server listening on port " + ar.result().actualPort());
    } else {
      log.error("Error starting MQTT server", ar.cause());
      System.exit(1);
    }
  });

  server.exceptionHandler(t -> context.assertTrue(false));
}
 
开发者ID:vert-x3,项目名称:vertx-mqtt,代码行数:30,代码来源:MqttClientSslTest.java

示例15: example1WithConfig

import io.vertx.core.net.PemKeyCertOptions; //导入依赖的package包/类
public void example1WithConfig(Vertx vertx) {
  JsonObject vault_config = new JsonObject()
    .put("host", "127.0.0.1") // The host name
    .put("port", 8200) // The port
    .put("ssl", true); // Whether or not SSL is used (disabled by default)

  // Certificates
  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());

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

  // 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,代码行数:28,代码来源:Examples.java


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