Example usage for io.vertx.core.http HttpClientOptions setTrustAll

List of usage examples for io.vertx.core.http HttpClientOptions setTrustAll

Introduction

In this page you can find the example usage for io.vertx.core.http HttpClientOptions setTrustAll.

Prototype

@Override
    public HttpClientOptions setTrustAll(boolean trustAll) 

Source Link

Usage

From source file:io.apiman.gateway.platforms.vertx3.http.HttpClientOptionsFactory.java

License:Apache License

private static HttpClientOptions doParse(TLSOptions tlsOptions, URI apiEndpoint) {
    HttpClientOptions clientOptions = new HttpClientOptions();

    if (apiEndpoint.getScheme().equals("http")) { //$NON-NLS-1$
        return clientOptions.setSsl(false);
    } else {//from w  w w .  j  a v  a  2s.  co m
        clientOptions.setSsl(true);
    }

    clientOptions.setTrustAll(tlsOptions.isTrustSelfSigned() || tlsOptions.isDevMode())
            .setVerifyHost(!tlsOptions.isAllowAnyHost() || tlsOptions.isDevMode());

    if (tlsOptions.getTrustStore() != null) {
        clientOptions.setTrustStoreOptions(new JksOptions().setPath(tlsOptions.getTrustStore())
                .setPassword(tlsOptions.getTrustStorePassword()));
    }

    if (tlsOptions.getKeyStore() != null) {
        clientOptions.setKeyStoreOptions(new JksOptions().setPath(tlsOptions.getKeyStore())
                .setPassword(tlsOptions.getKeyStorePassword()));
    }

    if (tlsOptions.getAllowedCiphers() != null) {
        String[] ciphers = arrayDifference(tlsOptions.getAllowedCiphers(), tlsOptions.getDisallowedCiphers(),
                getDefaultCipherSuites());
        for (String cipher : ciphers) {
            clientOptions.addEnabledCipherSuite(cipher);
        }
    }

    if (tlsOptions.getAllowedProtocols() != null) {
        log.info("Can't set allowed protocols on Vert.x gateway"); //$NON-NLS-1$
    }

    return clientOptions;
}

From source file:santo.vertx.reproducer.WebService.java

@Override
public void start() {
    System.out.println("Starting WebService");
    Router router = Router.router(vertx);

    // Add body handler
    router.route().handler(BodyHandler.create().setBodyLimit(10 * 1024 * 1024));

    HttpClientOptions options = new HttpClientOptions();
    options.setConnectTimeout(7000);/*w  w w  .  ja  v a 2 s . c  o  m*/
    options.setDefaultHost("internal.objectstore.eu");
    options.setDefaultPort(443);
    options.setSsl(true);
    options.setTrustAll(true);
    HttpClient http = vertx.createHttpClient(options);

    TestHandler handler = TestHandler.create(this, http);
    router.route("/api/test").handler(handler);

    vertx.createHttpServer().requestHandler(router::accept).listen(7000);
    System.out.println("WebService listening on port 7000");
}