Java 类io.vertx.core.net.PfxOptions 实例源码

项目:vertx-amqp-bridge    文件:VertxAmqpBridgeExamples.java   
public void example9(Vertx vertx) {
  AmqpBridgeOptions bridgeOptions = new AmqpBridgeOptions();
  bridgeOptions.setSsl(true);

  PfxOptions trustOptions = new PfxOptions().setPath("path/to/pkcs12.truststore")
                                            .setPassword("password");
  bridgeOptions.setPfxTrustOptions(trustOptions);

  PfxOptions keyCertOptions = new PfxOptions().setPath("path/to/pkcs12.keystore")
                                              .setPassword("password");
  bridgeOptions.setPfxKeyCertOptions(keyCertOptions);

  AmqpBridge bridge = AmqpBridge.create(vertx, bridgeOptions);
  bridge.start("localhost", 5672, res -> {
    // ..do things with the bridge..
  });
}
项目:vertx-proton    文件:ProtonClientSslTest.java   
@Test(timeout = 20000)
public void testConnectWithSslToNonSslServerFails(TestContext context) throws Exception {
  Async async = context.async();

  // Create a server that doesn't use ssl
  ProtonServerOptions serverOptions = new ProtonServerOptions();
  serverOptions.setSsl(false);

  protonServer = createServer(serverOptions, this::handleClientConnectionSessionReceiverOpen);

  // Try to connect the client and expect it to fail
  ProtonClientOptions clientOptions = new ProtonClientOptions();
  clientOptions.setSsl(true);
  PfxOptions pfxOptions = new PfxOptions().setPath(TRUSTSTORE).setPassword(PASSWORD);
  clientOptions.setPfxTrustOptions(pfxOptions);

  ProtonClient client = ProtonClient.create(vertx);
  client.connect(clientOptions, "localhost", protonServer.actualPort(), res -> {
    // Expect connect to fail due to remote peer not doing SSL
    context.assertFalse(res.succeeded());
    async.complete();
  });

  async.awaitSuccess();
}
项目:vertx-proton    文件:ProtonClientSslTest.java   
@Test(timeout = 20000)
public void testConnectWithSslToServerWhileUsingTrustAll(TestContext context) throws Exception {
  Async async = context.async();

  // Create a server that accept a connection and expects a client connection+session+receiver
  ProtonServerOptions serverOptions = new ProtonServerOptions();
  serverOptions.setSsl(true);
  PfxOptions serverPfxOptions = new PfxOptions().setPath(KEYSTORE).setPassword(PASSWORD);
  serverOptions.setPfxKeyCertOptions(serverPfxOptions);

  protonServer = createServer(serverOptions, this::handleClientConnectionSessionReceiverOpen);

  // Try to connect the client and expect it to succeed due to trusting all certs
  ProtonClientOptions clientOptions = new ProtonClientOptions();
  clientOptions.setSsl(true);
  clientOptions.setTrustAll(true);

  ProtonClient client = ProtonClient.create(vertx);
  client.connect(clientOptions, "localhost", protonServer.actualPort(), res -> {
    // Expect connect to succeed
    context.assertTrue(res.succeeded());
    async.complete();
  });

  async.awaitSuccess();
}
项目:hono    文件:AbstractConfig.java   
/**
 * 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;
    }
}
项目:hono    文件:AbstractConfigTest.java   
/**
 * Test a valid PFX configuration.
 */
@Test
public void testPfxConfig() {
    final TestConfig cfg = new TestConfig();
    cfg.setKeyStorePath(PREFIX_KEY_PATH + "honoKeyStore.p12");
    cfg.setKeyStorePassword("honokeys");

    final KeyCertOptions options = cfg.getKeyCertOptions();

    Assert.assertNotNull(options);
    Assert.assertThat(options, instanceOf(PfxOptions.class));
}
项目:enmasse    文件:AmqpServer.java   
@Override
public void start() {
    ProtonServerOptions options = new ProtonServerOptions();
    if(useTls) {
        options.setSsl(true);
        String path;
        if((path = config.get("jksKeyStorePath")) != null) {
            final JksOptions jksOptions = new JksOptions();
            jksOptions.setPath(path);
            jksOptions.setPassword(config.get("keyStorePassword"));
            options.setKeyStoreOptions(jksOptions);
        } else if((path = config.get("pfxKeyStorePath")) != null) {
            final PfxOptions pfxOptions = new PfxOptions();
            pfxOptions.setPath(path);
            pfxOptions.setPassword(config.get("keyStorePassword"));
            options.setPfxKeyCertOptions(pfxOptions);
        } else if((path = config.get("pemCertificatePath")) != null) {
            final PemKeyCertOptions pemKeyCertOptions = new PemKeyCertOptions();
            pemKeyCertOptions.setCertPath(path);
            pemKeyCertOptions.setKeyPath(config.get("pemKeyPath"));
            options.setPemKeyCertOptions(pemKeyCertOptions);
        } else {
            // use JDK settings?
        }

    }
    server = ProtonServer.create(vertx, options);

    server.saslAuthenticatorFactory(() -> new SaslAuthenticator(keycloakSessionFactory, config, useTls));
    server.connectHandler(this::connectHandler);
    LOG.info("Starting server on "+hostname+":"+ port);
    server.listen(port, hostname, event -> {
        if(event.failed())
        {
            LOG.error("Unable to listen for AMQP on "+hostname+":" + port, event.cause());
        }

    });
}
项目:vertx-amqp-bridge    文件:VertxAmqpBridgeExamples.java   
public void example8(Vertx vertx) {
  AmqpBridgeOptions bridgeOptions = new AmqpBridgeOptions();
  bridgeOptions.setSsl(true);

  PfxOptions trustOptions = new PfxOptions().setPath("path/to/pkcs12.truststore")
                                            .setPassword("password");
  bridgeOptions.setPfxTrustOptions(trustOptions);

  AmqpBridge bridge = AmqpBridge.create(vertx, bridgeOptions);
  bridge.start("localhost", 5672, "username", "password", res -> {
    // ..do things with the bridge..
  });
}
项目:vertx-amqp-bridge    文件:AmqpBridgeSslTest.java   
@Test(timeout = 20000)
public void testConnectWithSslSucceeds(TestContext context) throws Exception {
  Async async = context.async();

  ProtonServerOptions serverOptions = new ProtonServerOptions();
  serverOptions.setSsl(true);
  PfxOptions serverPfxOptions = new PfxOptions().setPath(KEYSTORE).setPassword(PASSWORD);
  serverOptions.setPfxKeyCertOptions(serverPfxOptions);

  mockServer = new MockServer(vertx, conn -> {
    handleBridgeStartupProcess(conn, context);
  }, serverOptions);

  // Start the bridge and verify is succeeds
  AmqpBridgeOptions bridgeOptions = new AmqpBridgeOptions();
  bridgeOptions.setSsl(true);
  PfxOptions clientPfxOptions = new PfxOptions().setPath(TRUSTSTORE).setPassword(PASSWORD);
  bridgeOptions.setPfxTrustOptions(clientPfxOptions);

  AmqpBridge bridge = AmqpBridge.create(vertx, bridgeOptions);
  bridge.start("localhost", mockServer.actualPort(), res -> {
    // Expect start to succeed
    context.assertTrue(res.succeeded(), "expected start to suceed");
    async.complete();
  });

  async.awaitSuccess();
}
项目:vertx-amqp-bridge    文件:AmqpBridgeSslTest.java   
@Test(timeout = 20000)
public void testConnectWithSslToNonSslServerFails(TestContext context) throws Exception {
  Async async = context.async();

  // Create a server that doesn't use ssl
  ProtonServerOptions serverOptions = new ProtonServerOptions();
  serverOptions.setSsl(false);

  mockServer = new MockServer(vertx, conn -> {
    handleBridgeStartupProcess(conn, context);
  }, serverOptions);

  // Try to start the bridge and expect it to fail
  AmqpBridgeOptions bridgeOptions = new AmqpBridgeOptions();
  bridgeOptions.setSsl(true);
  PfxOptions pfxOptions = new PfxOptions().setPath(TRUSTSTORE).setPassword(PASSWORD);
  bridgeOptions.setPfxTrustOptions(pfxOptions);

  AmqpBridge bridge = AmqpBridge.create(vertx, bridgeOptions);
  bridge.start("localhost", mockServer.actualPort(), res -> {
    // Expect start to fail due to remote peer not doing SSL
    context.assertFalse(res.succeeded(), "expected start to fail due to server not using secure transport");
    async.complete();
  });

  async.awaitSuccess();
}
项目:vertx-amqp-bridge    文件:AmqpBridgeSslTest.java   
@Test(timeout = 20000)
public void testConnectWithSslToServerWithUntrustedKeyFails(TestContext context) throws Exception {
  Async async = context.async();

  ProtonServerOptions serverOptions = new ProtonServerOptions();
  serverOptions.setSsl(true);
  PfxOptions serverPfxOptions = new PfxOptions().setPath(KEYSTORE).setPassword(PASSWORD);
  serverOptions.setPfxKeyCertOptions(serverPfxOptions);

  mockServer = new MockServer(vertx, conn -> {
    handleBridgeStartupProcess(conn, context);
  }, serverOptions);

  // Try to start the bridge and expect it to fail due to not trusting the server
  AmqpBridgeOptions bridgeOptions = new AmqpBridgeOptions();
  bridgeOptions.setSsl(true);
  PfxOptions pfxOptions = new PfxOptions().setPath(OTHER_CA_TRUSTSTORE).setPassword(PASSWORD);
  bridgeOptions.setPfxTrustOptions(pfxOptions);

  AmqpBridge bridge = AmqpBridge.create(vertx, bridgeOptions);
  bridge.start("localhost", mockServer.actualPort(), res -> {
    // Expect start to fail due to remote peer not being trusted
    context.assertFalse(res.succeeded(), "expected start to fail due to untrusted server");
    async.complete();
  });

  async.awaitSuccess();
}
项目:vertx-amqp-bridge    文件:AmqpBridgeSslTest.java   
@Test(timeout = 20000)
public void testConnectWithSslToServerWhileUsingTrustAll(TestContext context) throws Exception {
  Async async = context.async();

  ProtonServerOptions serverOptions = new ProtonServerOptions();
  serverOptions.setSsl(true);
  PfxOptions serverPfxOptions = new PfxOptions().setPath(KEYSTORE).setPassword(PASSWORD);
  serverOptions.setPfxKeyCertOptions(serverPfxOptions);

  mockServer = new MockServer(vertx, conn -> {
    handleBridgeStartupProcess(conn, context);
  }, serverOptions);

  // Try to start the bridge and expect it to succeed due to trusting all certs
  AmqpBridgeOptions bridgeOptions = new AmqpBridgeOptions();
  bridgeOptions.setSsl(true);
  bridgeOptions.setTrustAll(true);

  AmqpBridge bridge = AmqpBridge.create(vertx, bridgeOptions);
  bridge.start("localhost", mockServer.actualPort(), res -> {
    // Expect start to succeed
    context.assertTrue(res.succeeded(), "expected start to suceed due to trusting all certs");
    async.complete();
  });

  async.awaitSuccess();
}
项目:vertx-amqp-bridge    文件:AmqpBridgeSslTest.java   
private void doHostnameVerificationTestImpl(TestContext context, boolean verifyHost) throws Exception {

    Async async = context.async();

    ProtonServerOptions serverOptions = new ProtonServerOptions();
    serverOptions.setSsl(true);
    PfxOptions serverPfxOptions = new PfxOptions().setPath(WRONG_HOST_KEYSTORE).setPassword(PASSWORD);
    serverOptions.setPfxKeyCertOptions(serverPfxOptions);

    mockServer = new MockServer(vertx, conn -> {
      handleBridgeStartupProcess(conn, context);
    }, serverOptions);

    // Start the bridge
    AmqpBridgeOptions bridgeOptions = new AmqpBridgeOptions();
    bridgeOptions.setSsl(true);
    PfxOptions clientPfxOptions = new PfxOptions().setPath(TRUSTSTORE).setPassword(PASSWORD);
    bridgeOptions.setPfxTrustOptions(clientPfxOptions);

    // Verify/update the hostname verification settings
    context.assertEquals(VERIFY_HTTPS, bridgeOptions.getHostnameVerificationAlgorithm(),
        "expected host verification to be on by default");
    if (!verifyHost) {
      bridgeOptions.setHostnameVerificationAlgorithm(NO_VERIFY);
    }

    AmqpBridge bridge = AmqpBridge.create(vertx, bridgeOptions);
    bridge.start("localhost", mockServer.actualPort(), res -> {
      if (verifyHost) {
        // Expect start to fail
        context.assertFalse(res.succeeded(), "expected start to fail due to server cert not matching hostname");
      } else {
        // Expect start to succeed
        context.assertTrue(res.succeeded(), "expected start to suceed due to not verifying server hostname");
      }
      async.complete();
    });

    async.awaitSuccess();
  }
项目:vertx-proton    文件:ProtonClientSslTest.java   
@Test(timeout = 20000)
public void testConnectWithSslSucceeds(TestContext context) throws Exception {
  Async async = context.async();

  // Create a server that accept a connection and expects a client connection+session+receiver
  ProtonServerOptions serverOptions = new ProtonServerOptions();
  serverOptions.setSsl(true);
  PfxOptions serverPfxOptions = new PfxOptions().setPath(KEYSTORE).setPassword(PASSWORD);
  serverOptions.setPfxKeyCertOptions(serverPfxOptions);

  protonServer = createServer(serverOptions, this::handleClientConnectionSessionReceiverOpen);

  // Connect the client and open a receiver to verify the connection works
  ProtonClientOptions clientOptions = new ProtonClientOptions();
  clientOptions.setSsl(true);
  PfxOptions clientPfxOptions = new PfxOptions().setPath(TRUSTSTORE).setPassword(PASSWORD);
  clientOptions.setPfxTrustOptions(clientPfxOptions);

  ProtonClient client = ProtonClient.create(vertx);
  client.connect(clientOptions, "localhost", protonServer.actualPort(), res -> {
    // Expect connect to succeed
    context.assertTrue(res.succeeded());
    ProtonConnection connection = res.result();
    connection.open();

    ProtonReceiver receiver = connection.createReceiver("some-address");

    receiver.openHandler(recvResult -> {
      context.assertTrue(recvResult.succeeded());
      LOG.trace("Client reciever open");
      async.complete();
    }).open();
  });

  async.awaitSuccess();
}
项目:vertx-proton    文件:ProtonClientSslTest.java   
@Test(timeout = 20000)
public void testConnectWithSslToServerWithUntrustedKeyFails(TestContext context) throws Exception {
  Async async = context.async();

  // Create a server that accept a connection and expects a client connection+session+receiver
  ProtonServerOptions serverOptions = new ProtonServerOptions();
  serverOptions.setSsl(true);
  PfxOptions serverPfxOptions = new PfxOptions().setPath(KEYSTORE).setPassword(PASSWORD);
  serverOptions.setPfxKeyCertOptions(serverPfxOptions);

  protonServer = createServer(serverOptions, this::handleClientConnectionSessionReceiverOpen);

  // Try to connect the client and expect it to fail due to us not trusting the server
  ProtonClientOptions clientOptions = new ProtonClientOptions();
  clientOptions.setSsl(true);
  PfxOptions pfxOptions = new PfxOptions().setPath(OTHER_CA_TRUSTSTORE).setPassword(PASSWORD);
  clientOptions.setPfxTrustOptions(pfxOptions);

  ProtonClient client = ProtonClient.create(vertx);
  client.connect(clientOptions, "localhost", protonServer.actualPort(), res -> {
    // Expect connect to fail due to remote peer not doing SSL
    context.assertFalse(res.succeeded());
    async.complete();
  });

  async.awaitSuccess();
}
项目:vertx-proton    文件:ProtonClientSslTest.java   
private void doClientCertificateTestImpl(TestContext context, boolean supplyClientCert) throws InterruptedException,
                                                                                        ExecutionException {
  Async async = context.async();

  // Create a server that accept a connection and expects a client connection+session+receiver
  ProtonServerOptions serverOptions = new ProtonServerOptions();
  serverOptions.setSsl(true);
  serverOptions.setClientAuth(ClientAuth.REQUIRED);
  PfxOptions serverPfxOptions = new PfxOptions().setPath(KEYSTORE).setPassword(PASSWORD);
  serverOptions.setPfxKeyCertOptions(serverPfxOptions);

  PfxOptions pfxOptions = new PfxOptions().setPath(TRUSTSTORE).setPassword(PASSWORD);
  serverOptions.setPfxTrustOptions(pfxOptions);

  protonServer = createServer(serverOptions, this::handleClientConnectionSessionReceiverOpen);

  // Try to connect the client
  ProtonClientOptions clientOptions = new ProtonClientOptions();
  clientOptions.setSsl(true);
  clientOptions.setPfxTrustOptions(pfxOptions);

  if (supplyClientCert) {
    PfxOptions clientKeyPfxOptions = new PfxOptions().setPath(KEYSTORE_CLIENT).setPassword(PASSWORD);
    clientOptions.setPfxKeyCertOptions(clientKeyPfxOptions);
  }

  ProtonClient client = ProtonClient.create(vertx);
  client.connect(clientOptions, "localhost", protonServer.actualPort(), res -> {
    if (supplyClientCert) {
      // Expect connect to succeed
      context.assertTrue(res.succeeded());
    } else {
      // Expect connect to fail
      context.assertFalse(res.succeeded());
    }
    async.complete();
  });

  async.awaitSuccess();
}
项目:incubator-servicecomb-java-chassis    文件:VertxTLSBuilder.java   
private static TCPSSLOptions buildTCPSSLOptions(SSLOption sslOption, SSLCustom sslCustom,
    TCPSSLOptions tcpClientOptions) {
  tcpClientOptions.setSsl(true);
  if (isFileExists(sslCustom.getFullPath(sslOption.getKeyStore()))) {
    if (STORE_PKCS12.equalsIgnoreCase(sslOption.getKeyStoreType())) {
      PfxOptions keyPfxOptions = new PfxOptions();
      keyPfxOptions.setPath(sslCustom.getFullPath(sslOption.getKeyStore()));
      keyPfxOptions.setPassword(new String(sslCustom.decode(sslOption.getKeyStoreValue().toCharArray())));
      tcpClientOptions.setPfxKeyCertOptions(keyPfxOptions);
    } else if (STORE_JKS.equalsIgnoreCase(sslOption.getKeyStoreType())) {
      JksOptions keyJksOptions = new JksOptions();
      keyJksOptions.setPath(sslCustom.getFullPath(sslOption.getKeyStore()));
      keyJksOptions.setPassword(new String(sslCustom.decode(sslOption.getKeyStoreValue().toCharArray())));
      tcpClientOptions.setKeyStoreOptions(keyJksOptions);
    } else {
      throw new IllegalArgumentException("invalid key store type.");
    }
  }

  if (isFileExists(sslCustom.getFullPath(sslOption.getTrustStore()))) {
    if (STORE_PKCS12.equalsIgnoreCase(sslOption.getTrustStoreType())) {
      PfxOptions trustPfxOptions = new PfxOptions();
      trustPfxOptions.setPath(sslCustom.getFullPath(sslOption.getTrustStore()));
      trustPfxOptions
          .setPassword(new String(sslCustom.decode(sslOption.getTrustStoreValue().toCharArray())));
      tcpClientOptions.setPfxTrustOptions(trustPfxOptions);
    } else if (STORE_JKS.equalsIgnoreCase(sslOption.getTrustStoreType())) {
      JksOptions trustJksOptions = new JksOptions();
      trustJksOptions.setPath(sslCustom.getFullPath(sslOption.getTrustStore()));
      trustJksOptions
          .setPassword(new String(sslCustom.decode(sslOption.getTrustStoreValue().toCharArray())));
      tcpClientOptions.setTrustStoreOptions(trustJksOptions);
    } else {
      throw new IllegalArgumentException("invalid trust store type.");
    }
  }

  for (String protocol : sslOption.getProtocols().split(",")) {
    tcpClientOptions.addEnabledSecureTransportProtocol(protocol);
  }
  for (String cipher : SSLManager.getEnalbedCiphers(sslOption.getCiphers())) {
    tcpClientOptions.addEnabledCipherSuite(cipher);
  }

  if (isFileExists(sslCustom.getFullPath(sslOption.getCrl()))) {
    tcpClientOptions.addCrlPath(sslCustom.getFullPath(sslOption.getCrl()));
  }
  return tcpClientOptions;
}
项目:reactive-pg-client    文件:PgConnectOptions.java   
@Override
public PgConnectOptions setPfxKeyCertOptions(PfxOptions options) {
  return (PgConnectOptions)super.setPfxKeyCertOptions(options);
}
项目:reactive-pg-client    文件:PgConnectOptions.java   
@Override
public PgConnectOptions setPfxTrustOptions(PfxOptions options) {
  return (PgConnectOptions)super.setPfxTrustOptions(options);
}
项目:vertx-mqtt    文件:MqttServerOptions.java   
@Override
public MqttServerOptions setPfxKeyCertOptions(PfxOptions options) {
  super.setPfxKeyCertOptions(options);
  return this;
}
项目:vertx-mqtt    文件:MqttServerOptions.java   
@Override
public MqttServerOptions setPfxTrustOptions(PfxOptions options) {
  super.setPfxTrustOptions(options);
  return this;
}
项目:vertx-mqtt    文件:MqttClientOptions.java   
@Override
public MqttClientOptions setPfxKeyCertOptions(PfxOptions options) {
   super.setPfxKeyCertOptions(options);
   return this;
}
项目:vertx-mqtt    文件:MqttClientOptions.java   
@Override
public MqttClientOptions setPfxTrustOptions(PfxOptions options) {
   super.setPfxTrustOptions(options);
   return this;
}
项目:vertx-rest-client    文件:RestClientOptions.java   
@Override
public RestClientOptions setPfxKeyCertOptions(PfxOptions options) {
    super.setPfxKeyCertOptions(options);
    return this;
}
项目:vertx-rest-client    文件:RestClientOptions.java   
@Override
public RestClientOptions setPfxTrustOptions(PfxOptions options) {
    super.setPfxTrustOptions(options);
    return this;
}
项目:vertx-shell    文件:TelnetTermOptions.java   
@Override
public TelnetTermOptions setPfxKeyCertOptions(PfxOptions options) {
  return (TelnetTermOptions) super.setPfxKeyCertOptions(options);
}
项目:vertx-shell    文件:TelnetTermOptions.java   
@Override
public TelnetTermOptions setPfxTrustOptions(PfxOptions options) {
  return (TelnetTermOptions) super.setPfxTrustOptions(options);
}
项目:vertx-shell    文件:HttpTermOptions.java   
@Override
public HttpTermOptions setPfxKeyCertOptions(PfxOptions options) {
  return (HttpTermOptions) super.setPfxKeyCertOptions(options);
}
项目:vertx-shell    文件:HttpTermOptions.java   
@Override
public HttpTermOptions setPfxTrustOptions(PfxOptions options) {
  return (HttpTermOptions) super.setPfxTrustOptions(options);
}
项目:vertx-amqp-bridge    文件:AmqpBridgeOptions.java   
@Override
public AmqpBridgeOptions setPfxKeyCertOptions(PfxOptions options) {
  super.setPfxKeyCertOptions(options);
  return this;
}
项目:vertx-amqp-bridge    文件:AmqpBridgeOptions.java   
@Override
public AmqpBridgeOptions setPfxTrustOptions(PfxOptions options) {
  super.setPfxTrustOptions(options);
  return this;
}
项目:vertx-amqp-bridge    文件:AmqpBridgeSslTest.java   
private void doClientCertificateTestImpl(TestContext context, boolean supplyClientCert) throws InterruptedException,
                                                                                        ExecutionException {
  Async async = context.async();

  ProtonServerOptions serverOptions = new ProtonServerOptions();
  serverOptions.setSsl(true);
  serverOptions.setClientAuth(ClientAuth.REQUIRED);
  PfxOptions serverPfxOptions = new PfxOptions().setPath(KEYSTORE).setPassword(PASSWORD);
  serverOptions.setPfxKeyCertOptions(serverPfxOptions);

  PfxOptions pfxOptions = new PfxOptions().setPath(TRUSTSTORE).setPassword(PASSWORD);
  serverOptions.setPfxTrustOptions(pfxOptions);

  mockServer = new MockServer(vertx, conn -> {
    handleBridgeStartupProcess(conn, context);
  }, serverOptions);

  // Try to start the bridge
  AmqpBridgeOptions bridgeOptions = new AmqpBridgeOptions();
  bridgeOptions.setSsl(true);
  bridgeOptions.setPfxTrustOptions(pfxOptions);

  if (supplyClientCert) {
    PfxOptions clientKeyPfxOptions = new PfxOptions().setPath(KEYSTORE_CLIENT).setPassword(PASSWORD);
    bridgeOptions.setPfxKeyCertOptions(clientKeyPfxOptions);
  }

  AmqpBridge bridge = AmqpBridge.create(vertx, bridgeOptions);
  bridge.start("localhost", mockServer.actualPort(), res -> {
    if (supplyClientCert) {
      // Expect start to succeed
      context.assertTrue(res.succeeded(), "expected start to suceed due to supplying client certs");
    } else {
      // Expect start to fail
      context.assertFalse(res.succeeded(), "expected start to fail due to withholding client cert");
    }
    async.complete();
  });

  async.awaitSuccess();
}
项目:vertx-proton    文件:ProtonServerOptions.java   
@Override
public ProtonServerOptions setPfxKeyCertOptions(PfxOptions options) {
  super.setPfxKeyCertOptions(options);
  return this;
}
项目:vertx-proton    文件:ProtonServerOptions.java   
@Override
public ProtonServerOptions setPfxTrustOptions(PfxOptions options) {
  super.setPfxTrustOptions(options);
  return this;
}
项目:vertx-proton    文件:ProtonClientOptions.java   
@Override
public ProtonClientOptions setPfxKeyCertOptions(PfxOptions options) {
  super.setPfxKeyCertOptions(options);
  return this;
}
项目:vertx-proton    文件:ProtonClientOptions.java   
@Override
public ProtonClientOptions setPfxTrustOptions(PfxOptions options) {
  super.setPfxTrustOptions(options);
  return this;
}
项目:vertx-proton    文件:ProtonClientSslTest.java   
private void doHostnameVerificationTestImpl(TestContext context, boolean verifyHost) throws Exception {

    Async async = context.async();

    // Create a server that accept a connection and expects a client connection+session+receiver
    ProtonServerOptions serverOptions = new ProtonServerOptions();
    serverOptions.setSsl(true);
    PfxOptions serverPfxOptions = new PfxOptions().setPath(WRONG_HOST_KEYSTORE).setPassword(PASSWORD);
    serverOptions.setPfxKeyCertOptions(serverPfxOptions);

    protonServer = createServer(serverOptions, this::handleClientConnectionSessionReceiverOpen);

    // Connect the client and open a receiver to verify the connection works
    ProtonClientOptions clientOptions = new ProtonClientOptions();
    clientOptions.setSsl(true);
    PfxOptions clientPfxOptions = new PfxOptions().setPath(TRUSTSTORE).setPassword(PASSWORD);
    clientOptions.setPfxTrustOptions(clientPfxOptions);

    // Verify/update the hostname verification settings
    context.assertEquals(VERIFY_HTTPS, clientOptions.getHostnameVerificationAlgorithm(),
        "expected host verification to be on by default");
    if (!verifyHost) {
      clientOptions.setHostnameVerificationAlgorithm(NO_VERIFY);
    }

    ProtonClient client = ProtonClient.create(vertx);
    client.connect(clientOptions, "localhost", protonServer.actualPort(), res -> {
      if (verifyHost) {
        // Expect connect to fail as server cert hostname doesn't match.
        context.assertFalse(res.succeeded(), "expected connect to fail");
        LOG.trace("Connect failed");
        async.complete();
      } else {
        // Expect connect to succeed as verification is disabled
        context.assertTrue(res.succeeded(), "expected connect to succeed");
        LOG.trace("Connect succeeded");
        ProtonConnection connection = res.result();
        connection.open();

        ProtonReceiver receiver = connection.createReceiver("some-address");

        receiver.openHandler(recvResult -> {
          context.assertTrue(recvResult.succeeded());
          LOG.trace("Client receiver open");
          async.complete();
        }).open();
      }
    });

    async.awaitSuccess();
  }
项目:vertx-web    文件:WebClientOptions.java   
@Override
public WebClientOptions setPfxKeyCertOptions(PfxOptions options) {
  return (WebClientOptions) super.setPfxKeyCertOptions(options);
}
项目:vertx-web    文件:WebClientOptions.java   
@Override
public WebClientOptions setPfxTrustOptions(PfxOptions options) {
  return (WebClientOptions) super.setPfxTrustOptions(options);
}
项目:vertx-shell    文件:SSHTermOptions.java   
/**
 * Set the key pair options in pfx format.
 * @param options the key cert options in pfx format
 * @return a reference to this, so the API can be used fluently
 */
public SSHTermOptions setPfxKeyPairOptions(PfxOptions options) {
  this.keyPairOptions = options;
  return this;
}