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

项目:vertx-zero    文件:PemCert.java   
@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);
}
项目:DAVe    文件:GrpcPersistenceService.java   
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);
    }
}
项目: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;
}
项目:vertx-zero    文件:PfxCert.java   
@Override
public Handler<TCPSSLOptions> parse(final JsonObject config) {
    // TODO: PFX
    return null;
}
项目:vertx-zero    文件:JksCert.java   
@Override
public Handler<TCPSSLOptions> parse(final JsonObject config) {
    // TODO: JKS
    return null;
}
项目:vertx-zero    文件:CertPipe.java   
/**
 * Different pipe to parse JsonObject to generate Options
 *
 * @param options
 * @return
 */
Handler<TCPSSLOptions> parse(I options);