Read the cert

This commit is contained in:
Chocobozzz 2021-02-03 11:51:05 +01:00
parent 97fa5caed9
commit 9d977fd31c
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 8 additions and 3 deletions

View File

@ -1,15 +1,20 @@
import { readFileSync } from 'fs-extra'
import { flatMap } from 'lodash'
import { ApiResponse, Client } from '@elastic/elasticsearch'
import { CONFIG } from '../initializers/constants'
import { logger } from './logger'
import { flatMap } from 'lodash'
import { IndexableDoc } from '../types/elastic-search.model'
import { logger } from './logger'
const elasticOptions = {
node: CONFIG.ELASTIC_SEARCH.HTTP + '://' + CONFIG.ELASTIC_SEARCH.HOSTNAME + ':' + CONFIG.ELASTIC_SEARCH.PORT
}
if (CONFIG.ELASTIC_SEARCH.SSL.CA) {
Object.assign(elasticOptions, { ssl: { ca: CONFIG.ELASTIC_SEARCH.SSL.CA } })
Object.assign(elasticOptions, {
ssl: {
ca: readFileSync(CONFIG.ELASTIC_SEARCH.SSL.CA)
}
})
}
const elasticSearch = new Client(elasticOptions)