Search in sources :

Example 1 with SelfHostnameVerifier

use of com.alibaba.nacos.common.tls.SelfHostnameVerifier in project nacos by alibaba.

the class AbstractHttpClientFactory method initTls.

protected void initTls(BiConsumer<SSLContext, HostnameVerifier> initTlsBiFunc, TlsFileWatcher.FileChangeListener tlsChangeListener) {
    if (!TlsSystemConfig.tlsEnable) {
        return;
    }
    final HostnameVerifier hv = HttpsURLConnection.getDefaultHostnameVerifier();
    final SelfHostnameVerifier selfHostnameVerifier = new SelfHostnameVerifier(hv);
    initTlsBiFunc.accept(loadSSLContext(), selfHostnameVerifier);
    if (tlsChangeListener != null) {
        try {
            TlsFileWatcher.getInstance().addFileChangeListener(tlsChangeListener, TlsSystemConfig.tlsClientTrustCertPath, TlsSystemConfig.tlsClientKeyPath);
        } catch (IOException e) {
            assignLogger().error("add tls file listener fail", e);
        }
    }
}
Also used : SelfHostnameVerifier(com.alibaba.nacos.common.tls.SelfHostnameVerifier) IOException(java.io.IOException) HostnameVerifier(javax.net.ssl.HostnameVerifier) SelfHostnameVerifier(com.alibaba.nacos.common.tls.SelfHostnameVerifier) DefaultHostnameVerifier(org.apache.http.conn.ssl.DefaultHostnameVerifier)

Aggregations

SelfHostnameVerifier (com.alibaba.nacos.common.tls.SelfHostnameVerifier)1 IOException (java.io.IOException)1 HostnameVerifier (javax.net.ssl.HostnameVerifier)1 DefaultHostnameVerifier (org.apache.http.conn.ssl.DefaultHostnameVerifier)1