Skip to content

Commit

Permalink
fix(language-server): remove loading ssl/tls files to just passing f…
Browse files Browse the repository at this point in the history
…ile names VSCODE-292 (#347)
  • Loading branch information
Anemy authored Sep 29, 2021
1 parent 55a5fa2 commit b71ca61
Showing 1 changed file with 0 additions and 52 deletions.
52 changes: 0 additions & 52 deletions src/language/mongoDBService.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable no-sync */
import * as util from 'util';
import { CompletionItemKind, CancellationToken, Connection, CompletionItem, MarkupContent, MarkupKind } from 'vscode-languageserver/node';
import fs from 'fs';
import path from 'path';
import { signatures } from '@mongosh/shell-api';
import translator from '@mongosh/i18n';
Expand Down Expand Up @@ -46,45 +45,6 @@ export default class MongoDBService {
return this._connectionOptions;
}

_isSslConnection(connectionOptions: ConnectionOptions): boolean {
return !!(
connectionOptions &&
(connectionOptions.sslCA ||
connectionOptions.sslCert ||
connectionOptions.sslPass)
);
}

_readSslFileSync(sslOption: string | string[]): string | undefined {
if (Array.isArray(sslOption)) {
sslOption = sslOption[0];
}

if (typeof sslOption === 'string') {
return fs.readFileSync(sslOption).toString();
}
}

_loadSslBinaries(): void {
if (this._connectionOptions?.sslCA) {
this._connectionOptions.sslCA = this._readSslFileSync(
this._connectionOptions.sslCA
);
}

if (this._connectionOptions?.sslKey) {
this._connectionOptions.sslKey = this._readSslFileSync(
this._connectionOptions.sslKey
);
}

if (this._connectionOptions?.sslCert) {
this._connectionOptions.sslCert = this._readSslFileSync(
this._connectionOptions.sslCert
);
}
}

setExtensionPath(extensionPath: string): void {
if (!extensionPath) {
this._connection.console.log('Set extensionPath error: extensionPath is undefined');
Expand All @@ -111,18 +71,6 @@ export default class MongoDBService {
return Promise.resolve(false);
}

if (this._isSslConnection(this._connectionOptions)) {
try {
this._loadSslBinaries();
} catch (error) {
this._connection.console.log(
`SSL FILES read error: ${util.inspect(error)}`
);

return Promise.resolve(false);
}
}

try {
this._getDatabasesCompletionItems();

Expand Down

0 comments on commit b71ca61

Please sign in to comment.