Skip to content

Commit bf4903a

Browse files
committed
Add TLS support for rethinkdb
1 parent dadff3d commit bf4903a

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@
121121
"description": "Password for the RethinkDB connection.",
122122
"default": ""
123123
},
124+
"security-notes.collab.ssl": {
125+
"type": "string",
126+
"description": "SSL/TLS certificate file path for the RethinkDB connection (optional).",
127+
"default": ""
128+
},
124129
"security-notes.collab.projectName": {
125130
"type": "string",
126131
"description": "Project name used as the RethinkDB table.",

src/extension.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export function activate(context: vscode.ExtensionContext) {
2929
getSetting('collab.password'),
3030
getSetting('collab.database'),
3131
getSetting('collab.projectName'),
32+
getSetting('collab.ssl'),
3233
noteMap,
3334
);
3435
} else {

src/persistence/remote-db/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as vscode from 'vscode';
22
import * as rethinkdb from 'rethinkdb';
33
import { Serializer } from '../serialization/serializer';
44
import { Deserializer } from '../serialization/deserializer';
5+
import { readFileSync } from 'fs';
56

67
export class RemoteDb {
78
private host: string;
@@ -10,6 +11,7 @@ export class RemoteDb {
1011
private password: string;
1112
private database: string;
1213
private table: string;
14+
private ssl: string;
1315
private noteMap: Map<string, vscode.CommentThread>;
1416
private connection: any;
1517

@@ -20,6 +22,7 @@ export class RemoteDb {
2022
password: string,
2123
database: string,
2224
table: string,
25+
ssl: string,
2326
noteMap: Map<string, vscode.CommentThread>,
2427
) {
2528
this.host = host;
@@ -28,6 +31,7 @@ export class RemoteDb {
2831
this.password = password;
2932
this.database = database;
3033
this.table = table;
34+
this.ssl = ssl;
3135
this.noteMap = noteMap;
3236

3337
this.connect();
@@ -41,6 +45,12 @@ export class RemoteDb {
4145
db: this.database,
4246
user: this.username,
4347
password: this.password,
48+
ssl:
49+
this.ssl !== ''
50+
? {
51+
ca: readFileSync(this.ssl).toString().trim(),
52+
}
53+
: undefined,
4454
},
4555
(err: Error, conn: any) => {
4656
if (err) {

0 commit comments

Comments
 (0)