Search in sources :

Example 1 with JdkHttpClientRequest

use of com.alibaba.nacos.common.http.client.request.JdkHttpClientRequest in project nacos by alibaba.

the class AbstractHttpClientFactory method createNacosRestTemplate.

@Override
public NacosRestTemplate createNacosRestTemplate() {
    HttpClientConfig httpClientConfig = buildHttpClientConfig();
    final JdkHttpClientRequest clientRequest = new JdkHttpClientRequest(httpClientConfig);
    // enable ssl
    initTls(new BiConsumer<SSLContext, HostnameVerifier>() {

        @Override
        public void accept(SSLContext sslContext, HostnameVerifier hostnameVerifier) {
            clientRequest.setSSLContext(loadSSLContext());
            clientRequest.replaceSSLHostnameVerifier(hostnameVerifier);
        }
    }, new TlsFileWatcher.FileChangeListener() {

        @Override
        public void onChanged(String filePath) {
            clientRequest.setSSLContext(loadSSLContext());
        }
    });
    return new NacosRestTemplate(assignLogger(), clientRequest);
}
Also used : JdkHttpClientRequest(com.alibaba.nacos.common.http.client.request.JdkHttpClientRequest) TlsFileWatcher(com.alibaba.nacos.common.tls.TlsFileWatcher) SSLContext(javax.net.ssl.SSLContext) HostnameVerifier(javax.net.ssl.HostnameVerifier) SelfHostnameVerifier(com.alibaba.nacos.common.tls.SelfHostnameVerifier) DefaultHostnameVerifier(org.apache.http.conn.ssl.DefaultHostnameVerifier) NacosRestTemplate(com.alibaba.nacos.common.http.client.NacosRestTemplate)

Aggregations

NacosRestTemplate (com.alibaba.nacos.common.http.client.NacosRestTemplate)1 JdkHttpClientRequest (com.alibaba.nacos.common.http.client.request.JdkHttpClientRequest)1 SelfHostnameVerifier (com.alibaba.nacos.common.tls.SelfHostnameVerifier)1 TlsFileWatcher (com.alibaba.nacos.common.tls.TlsFileWatcher)1 HostnameVerifier (javax.net.ssl.HostnameVerifier)1 SSLContext (javax.net.ssl.SSLContext)1 DefaultHostnameVerifier (org.apache.http.conn.ssl.DefaultHostnameVerifier)1