Reputation: 9
I am getting the below error stack trace while querying the elastic from NodeJs app.
Error: Unable to load PFX certificate
at configSecureContext (node:internal/tls:304:15)
at Object.createSecureContext (node:_tls_common:113:3)
at Object.connect (node:_tls_wrap:1619:48)
at HttpsAgent.createConnection (node:https:136:22)
at HttpsAgent.createSocket (/Users/arshpreetsingh/Desktop/Desktop – MacBook Pro/Diagnotics Services/diagnostic-search/node_modules/agentkeepalive/lib/_http_agent.js:265:26)
at HttpsAgent.createSocket (/Users/arshpreetsingh/Desktop/Desktop – MacBook Pro/Diagnotics Services/diagnostic-search/node_modules/agentkeepalive/lib/agent.js:77:11)
at HttpsAgent.addRequest (/Users/arshpreetsingh/Desktop/Desktop – MacBook Pro/Diagnotics Services/diagnostic-search/node_modules/agentkeepalive/lib/_http_agent.js:239:10)
at new ClientRequest (node:_http_client:305:16)
at Object.request (node:https:317:10)
at Object.request (/Users/arshpreetsingh/Desktop/Desktop – MacBook Pro/Diagnotics Services/diagnostic-search/node_modules/agent-base/patch-core.js:25:22)
My elastc client looks like this.
import elasticsearch from 'elasticsearch';
import CONFIG from '../config/index';
const elasticClient = new elasticsearch.Client({
host: CONFIG.es_url,
});
export default {
search: async (...args) => {
try {
return await elasticClient.search(...args)
} catch (error) {
if (error.status == 400) {
return { hits: { total: 0 } }
}
throw error
}
}
}
The URL of the elastic search starts with https.
Upvotes: 1
Views: 5675
Reputation: 51
there is a way to solve this。
new elasticsearch.Client({ host: CONFIG.es_url, ssl:{ rejectUnauthorized: false } });
Upvotes: 4