Nodejs Elastic Client Setup is not working

I have setup elastic using eck guide this is working fine. i was able to run logstash by importing certificates. now im trying to write a nodejs api project to use my elastic search. trying some examples from docs

const client = new Client({
    node: '',
    maxRetries: 5,
    requestTimeout: 60000,
    sniffOnStart: true,
    ssl: {
        ca: fs.readFileSync('./cacert.crt'),
        rejectUnauthorized: false,
    auth: {
        password: ELASTIC_PWD,
        username: ELASTIC_USER

However it seems my ssl config is not working

const result = await{
      index: 'rush_idx',
      body: {
        query: {
          match: { isbn: "243453452" }

the above request fails with

ResponseError: security_exception
    at onBody (D:\Workspaces\RL.Elastic-API\node_modules\@elastic\elasticsearch\lib\Transport.js:333:23)
    at IncomingMessage.emit (events.js:327:22)
    at endReadableNT (_stream_readable.js:1327:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  meta: {
    body: { error: [Object], status: 401 },
    statusCode: 401,
    headers: {
      'www-authenticate': 'Basic realm="security" charset="UTF-8", Bearer realm="security", ApiKey',
      'content-type': 'application/json; charset=UTF-8',
      'content-length': '549'
    meta: {
      context: null,
      request: [Object],
      name: 'elasticsearch-js',
      connection: [Object],
      attempts: 0,
      aborted: false

can anybody tell what is correct way to configure ssl certificates in this case.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.