I am using Node JS with App Search 7.11.1 hosted on ECE 2.8.1. The following is the code to create an App Search client and to index a document. It is based on the official Elastic App Search NPM site.
const AppSearchClient = require('@elastic/app-search-node')
let documents = jsonDataLoader.loadJsonFile("C:\\Git\\SPS\\data\\jsondata.json");
const baseUrlFn = () => 'https://103e575486674f74bXXXXXXXXXXXXXXX.ece-playground.dev.sg:9243/api/as/v1/';
var asClient = new AppSearchClient(undefined, 'private-8bgcft2h2x2h1uXXXXXXXXXX', baseUrlFn);
for (const doc of documents) {
asClient.indexDocument('sharepoint-tap', JSON.stringify(doc))
.then(response => console.log(response))
.catch(error => console.log(error))
}
Upon running the code, there is a certificate error.
{ Error: unable to verify the first certificate
at TLSSocket. (_tls_wrap.js:1103:38)
at emitNone (events.js:106:13)
at TLSSocket.emit (events.js:208:7)
at TLSSocket._finishInit (_tls_wrap.js:637:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:467:38)
code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
errorMessages: [ 'unable to verify the first certificate' ] }
{ Error: unable to verify the first certificate
at TLSSocket. (_tls_wrap.js:1103:38)
at emitNone (events.js:106:13)
at TLSSocket.emit (events.js:208:7)
at TLSSocket._finishInit (_tls_wrap.js:637:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:467:38)
code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
errorMessages: [ 'unable to verify the first certificate' ] }
I then removed the https:// from the baseURLFn but got a protocol error.
errorMessages:
[ 'Invalid protocol: 103e575486674f74bXXXXXXXXXXXXXXXXXXXXXXXX.ece-playground.dev.sg:' ] }
How could the error be solved?