How to use spring-config-server with vertx using https?

Pranav Kumar :

I have a vert.x application and it is using spring-config-server to get values. When config-server is on http, the code works completely fine, but when spring-config-server is moved to https, the code does not work.

Vertx vertx = Vertx.vertx();
List<ConfigStoreOptions> configStores = new ArrayList<>();
List<String> configUrls = CoreConfigBean.getUrls(environment);
configUrls.forEach(url -> {
    configStores.add(new ConfigStoreOptions().setType("spring-config-server")
            .setConfig(new JsonObject().put("url", url).put("timeout",
                    Long.parseLong(ConfigurationUtil.CONFIG_SERVER_TIME_OUT))));
});
ConfigRetrieverOptions configRetrieverOptions = new ConfigRetrieverOptions();
configStores.forEach(configRetrieverOptions::addStore);
ConfigRetriever retriever = ConfigRetriever.create(vertx, configRetrieverOptions.setScanPeriod(0));
CompletableFuture<JsonObject> configLoader = new CompletableFuture<JsonObject>();
retriever.getConfig(json -> {
    if (json.succeeded()) {
        JsonObject jsonObject = json.result();
        if (jsonObject != null) {
            jsonObject.iterator().forEachRemaining(sourceValue -> System.setProperty(sourceValue.getKey(),
                    sourceValue.getValue().toString()));
        }
        configLoader.complete(json.result());
        json.mapEmpty();
        retriever.close();
        vertx.close();
    } else {
        json.otherwiseEmpty();
        retriever.close();
        vertx.close();
    }
});
configLoader.get();
taygetos :

Try to specify the HttpClientOptions by providing the httpClientConfiguration element in the configuration:

 ...
 .setConfig(new JsonObject()
     .put("url", url)
     .put("timeout", Long.parseLong(ConfigurationUtil.CONFIG_SERVER_TIME_OUT))
     .put("httpClientConfiguration", new JsonObject()
         .put("trustAll", true) 
         .put("ssl", true)));
 ...

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=162587&siteId=1