X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=ves-nf-oam-adopter%2Fves-nf-oam-adopter-app%2Fsrc%2Fmain%2Fjava%2Forg%2Fo%2Fran%2Foam%2Fnf%2Foam%2Fadopter%2Fapp%2Fhttp%2FHttpCientFactory.java;h=7184c28ed3f1c5919961d524b4326fdf9efbb7c3;hb=cbc3da1f8c19847297e2ad88ba4f70210605b59e;hp=073a62212f528c5e0b632e94a46cf2ec65ba5ab6;hpb=e4d3cdf5d8679fdad10e12d16d0913b9754049a4;p=oam%2Fnf-oam-adopter.git diff --git a/ves-nf-oam-adopter/ves-nf-oam-adopter-app/src/main/java/org/o/ran/oam/nf/oam/adopter/app/http/HttpCientFactory.java b/ves-nf-oam-adopter/ves-nf-oam-adopter-app/src/main/java/org/o/ran/oam/nf/oam/adopter/app/http/HttpCientFactory.java index 073a622..7184c28 100644 --- a/ves-nf-oam-adopter/ves-nf-oam-adopter-app/src/main/java/org/o/ran/oam/nf/oam/adopter/app/http/HttpCientFactory.java +++ b/ves-nf-oam-adopter/ves-nf-oam-adopter-app/src/main/java/org/o/ran/oam/nf/oam/adopter/app/http/HttpCientFactory.java @@ -19,7 +19,6 @@ package org.o.ran.oam.nf.oam.adopter.app.http; -import com.google.common.base.Strings; import java.io.File; import java.io.IOException; import java.security.KeyManagementException; @@ -37,10 +36,8 @@ import org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager; import org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManagerBuilder; import org.apache.hc.client5.http.ssl.ClientTlsStrategyBuilder; import org.apache.hc.client5.http.ssl.NoopHostnameVerifier; -import org.apache.hc.client5.http.ssl.TrustAllStrategy; import org.apache.hc.core5.http2.HttpVersionPolicy; import org.apache.hc.core5.ssl.SSLContextBuilder; -import org.apache.hc.core5.ssl.SSLContexts; import org.apache.hc.core5.util.Timeout; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -56,15 +53,7 @@ public final class HttpCientFactory { final String trustStorePassword, final Long conectionTimeout, final Long responseTimeout) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException, CertificateException { - if (Strings.isNullOrEmpty(trustStore) || Strings.isNullOrEmpty(trustStorePassword)) { - return trustAllCertificate(conectionTimeout, responseTimeout); - } - final File trustStoreFilePath = new File(trustStore); - if (!trustStoreFilePath.exists() || trustStoreFilePath.isDirectory()) { - return trustAllCertificate(conectionTimeout, responseTimeout); - } - - final SSLContext sslContext = getSslContext(trustStoreFilePath, trustStorePassword); + final SSLContext sslContext = getSslContext(new File(trustStore), trustStorePassword); return trustTrustStore(sslContext, conectionTimeout, responseTimeout); } @@ -101,23 +90,4 @@ public final class HttpCientFactory { .setCookieSpec(StandardCookieSpec.STRICT) .build(); } - - private static CloseableHttpAsyncClient trustAllCertificate(final Long conectionTimeout, final Long responseTimeout) - throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException { - LOG.info("Trust all SSL certificates"); - final SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(new TrustAllStrategy()).build(); - final PoolingAsyncClientConnectionManager connectionManager = - PoolingAsyncClientConnectionManagerBuilder.create() - .setTlsStrategy(ClientTlsStrategyBuilder.create() - .setSslContext(sslContext) - .setHostnameVerifier(NoopHostnameVerifier.INSTANCE) - .build()) - .build(); - - return HttpAsyncClients.custom() - .setConnectionManager(connectionManager) - .setDefaultRequestConfig(createDefaultRequestConfig(conectionTimeout, responseTimeout)) - .setVersionPolicy(HttpVersionPolicy.NEGOTIATE) - .build(); - } }