@Override
    public KafkaChannel buildChannel(String id, SelectionKey key, int maxReceiveSize,
                                     MemoryPool memoryPool, ChannelMetadataRegistry metadataRegistry) throws KafkaException {
        SslTransportLayer transportLayer = null;
        try {
            transportLayer = buildTransportLayer(sslFactory, id, key, metadataRegistry);
            final SslTransportLayer finalTransportLayer = transportLayer;
            Supplier<Authenticator> authenticatorCreator = () ->
                new SslAuthenticator(configs, finalTransportLayer, listenerName, sslPrincipalMapper);
            return new KafkaChannel(id, transportLayer, authenticatorCreator, maxReceiveSize,
                    memoryPool != null ? memoryPool : MemoryPool.NONE, metadataRegistry);
        } catch (Exception e) {
            // Ideally these resources are closed by the KafkaChannel but this builder should close the resources instead
            // if an error occurs due to which KafkaChannel is not created.
            Utils.closeQuietly(transportLayer, "transport layer for channel Id: " + id);
            throw new KafkaException(e);
        }
    }
Constructs an SSL channel builder. ListenerName is provided only
for server channel builder and will be null for client channel builder.
clients/src/main/java/org/apache/kafka/common/network/SslChannelBuilder.java