Skip to content

Commit

Permalink
Disable endpoint verification for schema registry client (#2284) (#2285
Browse files Browse the repository at this point in the history
…) (#2287)

Co-authored-by: Prathamesh <prathameshmane1234@gmail.com>

Co-authored-by: Anshul Goyal <agoyal@confluent.io>
Co-authored-by: Prathamesh <prathameshmane1234@gmail.com>

Co-authored-by: Anshul Goyal <agoyal@confluent.io>
Co-authored-by: Prathamesh <prathameshmane1234@gmail.com>
  • Loading branch information
3 people committed May 17, 2022
1 parent 83ee3b5 commit 914dd31
Showing 1 changed file with 18 additions and 0 deletions.
Expand Up @@ -23,6 +23,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.kafka.common.config.SslConfigs;

import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -52,6 +54,8 @@
import io.confluent.kafka.schemaregistry.client.security.SslFactory;
import io.confluent.kafka.schemaregistry.utils.BoundedConcurrentHashMap;

import javax.net.ssl.HostnameVerifier;


/**
* Thread-safe Schema Registry Client with client side caching.
Expand Down Expand Up @@ -228,10 +232,24 @@ public CachedSchemaRegistryClient(
SslFactory sslFactory = new SslFactory(sslConfigs);
if (sslFactory.sslContext() != null) {
restService.setSslSocketFactory(sslFactory.sslContext().getSocketFactory());
restService.setHostnameVerifier(getHostnameVerifier(sslConfigs));
}
}
}

private HostnameVerifier getHostnameVerifier(Map<String, Object> config) {
String sslEndpointIdentificationAlgo =
(String) config.get(SslConfigs.SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_CONFIG);

if (sslEndpointIdentificationAlgo == null
|| sslEndpointIdentificationAlgo.equals("none")
|| sslEndpointIdentificationAlgo.isEmpty()) {
return (hostname, session) -> true;
}

return null;
}

@Override
public Optional<ParsedSchema> parseSchema(
String schemaType,
Expand Down

0 comments on commit 914dd31

Please sign in to comment.