Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[elasticsearch] allow defining multiple ca certs #5246

Merged
merged 1 commit into from
Oct 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/plugins/elasticsearch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = function (kibana) {
startupTimeout: Joi.number().default(5000),
ssl: Joi.object({
verify: Joi.boolean().default(true),
ca: Joi.string(),
ca: Joi.array().single().items(Joi.string()),
cert: Joi.string(),
key: Joi.string()
}).default(),
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/elasticsearch/lib/create_agent.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var url = require('url');
var _ = require('lodash');
var readFile = _.partialRight(require('fs').readFileSync, 'utf8');
var readFile = (file) => require('fs').readFileSync(file, 'utf8');
var http = require('http');
var https = require('https');

Expand All @@ -14,8 +14,8 @@ module.exports = _.memoize(function (server) {
rejectUnauthorized: config.get('elasticsearch.ssl.verify')
};

if (config.get('elasticsearch.ssl.ca')) {
agentOptions.ca = [readFile(config.get('elasticsearch.ssl.ca'))];
if (_.size(config.get('elasticsearch.ssl.ca'))) {
agentOptions.ca = config.get('elasticsearch.ssl.ca').map(readFile);
}

// Add client certificate and key if required by elasticsearch
Expand All @@ -29,4 +29,4 @@ module.exports = _.memoize(function (server) {

// See https://lodash.com/docs#memoize: We use a Map() instead of the default, because we want the keys in the cache
// to be the server objects, and by default these would be coerced to strings as keys (which wouldn't be useful)
module.exports.cache = new Map();
module.exports.cache = new Map();
8 changes: 4 additions & 4 deletions src/plugins/elasticsearch/lib/expose_client.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var elasticsearch = require('elasticsearch');
var _ = require('lodash');
var fs = require('fs');
var readFile = (file) => require('fs').readFileSync(file, 'utf8');
var util = require('util');
var url = require('url');
var callWithRequest = require('./call_with_request');
Expand Down Expand Up @@ -31,11 +31,11 @@ module.exports = function (server) {

var ssl = { rejectUnauthorized: options.verifySsl };
if (options.clientCrt && options.clientKey) {
ssl.cert = fs.readFileSync(options.clientCrt, 'utf8');
ssl.key = fs.readFileSync(options.clientKey, 'utf8');
ssl.cert = readFile(options.clientCrt);
ssl.key = readFile(options.clientKey);
}
if (options.ca) {
ssl.ca = fs.readFileSync(options.ca, 'utf8');
ssl.ca = options.ca.map(readFile);
}

return new elasticsearch.Client({
Expand Down