mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
Fixes the client to setup SSL with the CA certificates for testing (#65598)
## Summary Fixes the non-legacy ES test client to work with SSL. Without this if you try to migrate `siem rules` or `alerting` or `CASE` or anything else that is using SSL based tests you get this error when trying to use the non-legacy: ```ts // pull in non-legacy service for functional tests const es = getService('es'); ``` ```ts // use it somewhere where your config.ts is utilizing SSL in a functional test // ... ``` In your console you get this error: ```ts ConnectionError: self signed certificate in certificate chain at onResponse (node_modules/@elastic/elasticsearch/lib/Transport.js:205:13) at ClientRequest.request.on.err (node_modules/@elastic/elasticsearch/lib/Connection.js:98:9) at TLSSocket.socketErrorListener (_http_client.js:401:9) at emitErrorNT (internal/streams/destroy.js:91:8) at emitErrorAndCloseNT (internal/streams/destroy.js:59:3) at process._tickCallback (internal/process/next_tick.js:63:19) ``` This fixes that by adding the CA certs from test to the ES test client.
This commit is contained in:
parent
8373247da0
commit
0d3ddbe9d0
1 changed files with 5 additions and 1 deletions
|
@ -18,8 +18,9 @@
|
|||
*/
|
||||
|
||||
import { format as formatUrl } from 'url';
|
||||
|
||||
import fs from 'fs';
|
||||
import { Client } from '@elastic/elasticsearch';
|
||||
import { CA_CERT_PATH } from '@kbn/dev-utils';
|
||||
|
||||
import { FtrProviderContext } from '../ftr_provider_context';
|
||||
|
||||
|
@ -27,6 +28,9 @@ export function ElasticsearchProvider({ getService }: FtrProviderContext) {
|
|||
const config = getService('config');
|
||||
|
||||
return new Client({
|
||||
ssl: {
|
||||
ca: fs.readFileSync(CA_CERT_PATH, 'utf-8'),
|
||||
},
|
||||
nodes: [formatUrl(config.get('servers.elasticsearch'))],
|
||||
requestTimeout: config.get('timeouts.esRequestTimeout'),
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue