Skip to content

Commit

Permalink
[wip] Add ssl options to create-test-tables script
Browse files Browse the repository at this point in the history
  • Loading branch information
charmander committed Oct 31, 2020
1 parent 7f74239 commit 4c2fce2
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions packages/pg/script/create-test-tables.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict'
var fs = require('fs')
var args = require('../test/cli')
var pg = require('../lib')

Expand Down Expand Up @@ -31,13 +32,31 @@ var people = [
{ name: 'Zanzabar', age: 260 },
]

var con = new pg.Client({
var config = {
host: args.host,
port: args.port,
user: args.user,
password: args.password,
database: args.database,
})
}

if (process.env.PGSSLMODE) {
config.ssl = {}

if (process.env.PGSSLROOTCERT) {
config.ssl.ca = fs.readFileSync(process.env.PGSSLROOTCERT)
}

if (process.env.PGSSLCERT) {
config.ssl.cert = fs.readFileSync(process.env.PGSSLCERT)
}

if (process.env.PGSSLKEY) {
config.ssl.key = fs.readFileSync(process.env.PGSSLKEY)
}
}

var con = new pg.Client(config)

con.connect((err) => {
if (err) {
Expand Down

0 comments on commit 4c2fce2

Please sign in to comment.