skip to Main Content

I have a working jdbc sink connector configuration for postgres using username and password configuration:

{
    "connector.class": "io.confluent.connect.jdbc.JdbcSinkConnector",
    "connection.url": "jdbc:postgresql://localhost:5432/postgres",
    "connection.user": "postgres-user",
    "connection.password": "postgres-pw",
    "topics.regex": "my-topic",
    "transforms": "unwrap",
    "transforms.unwrap.type": "io.debezium.transforms.ExtractNewRecordState",
    "transforms.unwrap.drop.tombstones": "false",    
    "key.converter": "org.apache.kafka.connect.json.JsonConverter",
    "key.converter.schemas.enable": "false",
    "value.converter": "org.apache.kafka.connect.json.JsonConverter",
    "value.converter.schemas.enable": "false",
    "auto.create": "true",
    "insert.mode": "upsert",
    "auto.evolve": "true",
    "table.name.format" : "${topic}",
    "pk.mode": "record_key",
    "pk.fields": "id",
}

But I want to connect the same exact connector to postgres server that uses ssl connection which demands a username, .cert file and .key file.

But in the documantation I only see ssl.rootcertfile configuration option, which is not the same as cert and key file.

I was wondering if it is possible to set the .cert and .key file in the connector configuration?

2

Answers


  1. Chosen as BEST ANSWER

    I managed to find the answer myself: So actually all the required properties can go inside the connection url according to the docs like so:

    jdbc:postgresql://localhost:5432/postgres?sslmode=require&sslcert=/path/to/certfile.crt&sslkey=/path/to/keyfile.key
    

    Another thing that was very important in my case, is that the Kafka connect image that I used (which is the confluent image) could only use a DER key file and would not accept a PEM keyfile. So I had to convert my pem file to der file with this command:

    openssl pkcs8 -topk8 -inform PEM -outform DER -in postgresql.key -out -no crypt postgresql.pk8
    

    And then just use the output keyfile postgresql.pk8 as the path to sslkey in the connection string.


  2. You’d modify the connection url to add at least ?ssl=true

    https://jdbc.postgresql.org/documentation/use/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search