简体   繁体   中英

node.js elasticsearch self signed certificate in certificate chain

I've been trying to learn elasticsearch and decided to try to connect it with node.js. I have a elasticsearch running + a index I created named test-idx. I'm following the documentation of elasticsearch to connect and create a document however when I run my code I get 'ConnectionError: self signed certificate in certificate chain' followed by a huge meta object.

const client = new elasticsearch.Client({
    node: 'https://localhost:9200',
    auth: {
      username: 'elastic',
      password: '123456'
    }
})

client.index({
    index: 'test-idx',
    document: {
        field: 'test123'
    }
  })

I tried adding when creating the instance of the Client but it didn't seem to help

tls: {
    rejectUnauthorized: false
  }

I'm my case it's Working. I'm using node with nest js

tls: { rejectUnauthorized: false }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM