File tree 1 file changed +21
-2
lines changed
1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change 1
1
'use strict'
2
+ var fs = require ( 'fs' )
2
3
var args = require ( '../test/cli' )
3
4
var pg = require ( '../lib' )
4
5
@@ -31,13 +32,31 @@ var people = [
31
32
{ name : 'Zanzabar' , age : 260 } ,
32
33
]
33
34
34
- var con = new pg . Client ( {
35
+ var config = {
35
36
host : args . host ,
36
37
port : args . port ,
37
38
user : args . user ,
38
39
password : args . password ,
39
40
database : args . database ,
40
- } )
41
+ }
42
+
43
+ if ( process . env . PGSSLMODE ) {
44
+ config . ssl = { }
45
+
46
+ if ( process . env . PGSSLROOTCERT ) {
47
+ config . ssl . ca = fs . readFileSync ( process . env . PGSSLROOTCERT )
48
+ }
49
+
50
+ if ( process . env . PGSSLCERT ) {
51
+ config . ssl . cert = fs . readFileSync ( process . env . PGSSLCERT )
52
+ }
53
+
54
+ if ( process . env . PGSSLKEY ) {
55
+ config . ssl . key = fs . readFileSync ( process . env . PGSSLKEY )
56
+ }
57
+ }
58
+
59
+ var con = new pg . Client ( config )
41
60
42
61
con . connect ( ( err ) => {
43
62
if ( err ) {
You can’t perform that action at this time.
0 commit comments