add ssl encryption to kafka client
parent
3932583bc9
commit
ad1eea98b1
10
lib/kafka.js
10
lib/kafka.js
|
@ -8,11 +8,17 @@ const log = debug('umami:kafka');
|
||||||
function getClient() {
|
function getClient() {
|
||||||
const { username, password } = new URL(process.env.KAFKA_URL);
|
const { username, password } = new URL(process.env.KAFKA_URL);
|
||||||
const brokers = process.env.KAFKA_BROKER.split(',');
|
const brokers = process.env.KAFKA_BROKER.split(',');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
const ssl =
|
const ssl =
|
||||||
username && password
|
username && password
|
||||||
? {
|
? {
|
||||||
ssl: true,
|
ssl: {
|
||||||
|
checkServerIdentity: () => undefined,
|
||||||
|
ca: [fs.readFileSync('./cert/ca_cert.pem', 'utf-8')],
|
||||||
|
key: fs.readFileSync('./cert/client_key.pem', 'utf-8'),
|
||||||
|
cert: fs.readFileSync('./cert/client_cert.pem', 'utf-8'),
|
||||||
|
},
|
||||||
sasl: {
|
sasl: {
|
||||||
mechanism: 'plain',
|
mechanism: 'plain',
|
||||||
username,
|
username,
|
||||||
|
@ -63,7 +69,7 @@ async function sendMessage(params, topic) {
|
||||||
value: JSON.stringify(params),
|
value: JSON.stringify(params),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
acks: 0,
|
acks: 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue