Просмотр исходного кода

Switch between ssl and tls depending on es version

Shun Miyazawa 2 лет назад
Родитель
Сommit
01339f44b3
1 измененных файлов с 6 добавлено и 1 удалено
  1. 6 1
      apps/app/src/server/service/search-delegator/elasticsearch.ts

+ 6 - 1
apps/app/src/server/service/search-delegator/elasticsearch.ts

@@ -119,11 +119,16 @@ class ElasticsearchDelegator implements SearchDelegator<Data, ESTermsKey, ESQuer
   initClient() {
   initClient() {
     const { host, auth, indexName } = this.getConnectionInfo();
     const { host, auth, indexName } = this.getConnectionInfo();
 
 
+    const elasticsearchRejectUnauthorized = this.configManager.getConfig('crowi', 'app:elasticsearchRejectUnauthorized');
+    const encryptionOption = this.isElasticsearchV7
+      ? { ssl: { rejectUnauthorized: elasticsearchRejectUnauthorized } }
+      : { tls: { rejectUnauthorized: elasticsearchRejectUnauthorized } };
+
     this.client = new ElasticsearchClient(new this.elasticsearch.Client({
     this.client = new ElasticsearchClient(new this.elasticsearch.Client({
       node: host,
       node: host,
-      ssl: { rejectUnauthorized: this.configManager.getConfig('crowi', 'app:elasticsearchRejectUnauthorized') },
       auth,
       auth,
       requestTimeout: this.configManager.getConfig('crowi', 'app:elasticsearchRequestTimeout'),
       requestTimeout: this.configManager.getConfig('crowi', 'app:elasticsearchRequestTimeout'),
+      ...encryptionOption,
     }));
     }));
     this.indexName = indexName;
     this.indexName = indexName;
   }
   }