Thank you, @Cagri ! Your example works for me too.
But we create mm2 connector in distributed mode using kafka connect restAPI and it works differently.
I've found the solution. It turns out there're group of specific parameters like that:
source.consumer.security.protocol
target.producer.security.protocol
source.admin.security.protocol
target.admin.security.protocol
and so on. So now my config looks like this and it works:
//mm2.json
{
"name": "my_mm2_connector",
"config":
{
"connector.class": "org.apache.kafka.connect.mirror.MirrorSourceConnector",
"source.cluster.alias": "src",
"target.cluster.alias": "tgt",
"source.cluster.bootstrap.servers": "kafa_sasl_ssl:9092",
"target.cluster.bootstrap.servers": "kafka_plaintext:9092",
"topics": "test_topic",
"tasks.max": 1,
"replication.factor": 1,
"offset-syncs.topic.replication.factor": 1,
"offset-syncs.topic.location": "target",
"enabled": true,
"source.security.protocol": "SASL_SSL",
"source.ssl.keystore.type": "JKS",
"source.ssl.truststore.type": "JKS",
"source.ssl.truststore.location": "/opt/ssl/kafka.truststore.jks",
"source.ssl.keystore.password": "changeit",
"source.ssl.keystore.location": "/opt/ssl/kafka.keystore.jks",
"source.ssl.truststore.password": "changeit",
"source.sasl.mechanism": "PLAIN",
"source.sasl.jaas.config": "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"kafka\" password=\"kafka-password\";",
"source.consumer.security.protocol": "SASL_SSL",
"source.consumer.ssl.keystore.type": "JKS",
"source.consumer.ssl.truststore.type": "JKS",
"source.consumer.ssl.truststore.location": "/opt/ssl/kafka.truststore.jks",
"source.consumer.ssl.keystore.password": "changeit",
"source.consumer.ssl.keystore.location": "/opt/ssl/kafka.keystore.jks",
"source.consumer.ssl.truststore.password": "changeit",
"source.consumer.sasl.mechanism": "PLAIN",
"source.consumer.sasl.jaas.config": "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"kafka\" password=\"kafka-password\";",
"source.admin.security.protocol": "SASL_SSL",
"source.admin.ssl.keystore.type": "JKS",
"source.admin.ssl.truststore.type": "JKS",
"source.admin.ssl.truststore.location": "/opt/ssl/kafka.truststore.jks",
"source.admin.ssl.keystore.password": "changeit",
"source.admin.ssl.keystore.location": "/opt/ssl/kafka.keystore.jks",
"source.admin.ssl.truststore.password": "changeit",
"source.admin.sasl.mechanism": "PLAIN",
"source.admin.sasl.jaas.config": "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"kafka\" password=\"kafka-password\";",
"target.security.protocol": "PLAINTEXT"
}
}
root@kafka$>curl -X POST -H "Content-Type: application/json" http://kafka-connect:8083/connectors -d @mm2.json