Connect to Kafka with TrustStore KeyStore certificates in .NET

first100 81 Reputation points
2023-03-07T09:14:25.3933333+00:00

Hello,

I have to connect to some kafka instances, i was able to connect with this instances in plaintext one month ago, now i have to use authorization. I have two file, a keystore.jks and truststore.jks and related passwords, provided me by devops, i suppose when i create class ConsumerConfig i have to pass parameters related to authentication , but despite my efforts i cant authenticate with kafka.

i receive:

Disconnected while requesting ApiVersion: might be caused by incorrect security.protocol configuration (connecting to a SSL listener?)

Some other teammates that works in java was able to connect using these two file.

Can someone help me?

Thanks


 var cons = new ConsumerConfig
        {
            GroupId = appSettings.GroupId,
            BootstrapServers = appSettings.BootstrapServers,
            Acks = Acks.All,
            AutoOffsetReset = AutoOffsetReset.Earliest,
            Debug = "debug,channel",
            EnableAutoCommit = false,
            SecurityProtocol = SecurityProtocol.Ssl,
            SaslMechanism = SaslMechanism.ScramSha256,
            
            SslKeystoreLocation = @"C:\dev.keystore.jks",
            SslKeystorePassword = "keystorepassword",
            SslCaLocation = @"C:\dev.keystore.jks",

            SslCertificateLocation = @"C:\kafkadev.truststore.jks",
            SslKeyPassword = "truststorepassword"
        };


Disconnected while requesting ApiVersion: might be caused by incorrect security.protocol configuration (connecting to a SSL listener?)

Some other teammates that works in java was able to connect using these two file.
Can someone help me?
Thanks
Developer technologies C#
{count} votes

1 answer

Sort by: Most helpful
  1. santosh kumar 0 Reputation points
    2023-04-26T10:12:27.7033333+00:00

    If the client is c# we have to convert .jks to .pem file and use it in c#. Here you have to convert keystore and trustore to .pem file formats. https://github.com/edenhill/kcat/issues/309

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.