@@ -25,9 +25,11 @@ var val = function (key, config, envVar) {
25
25
return config [ key ] || envVar || defaults [ key ]
26
26
}
27
27
28
- var useSsl = function ( modeFromConfig ) {
28
+ var normalizeSSLConfig = function ( modeFromConfig ) {
29
29
// if the ssl parameter passed to config is not a string, just return it
30
30
// directly (it will be passed directly to tls.connect)
31
+ // this way you can pass all the ssl params in via constructor:
32
+ // new Client({ ssl: { minDHSize: 1024 } }) etc
31
33
if ( modeFromConfig !== undefined && typeof modeFromConfig !== 'string' ) {
32
34
return modeFromConfig
33
35
}
@@ -41,6 +43,11 @@ var useSsl = function (modeFromConfig) {
41
43
case 'verify-ca' :
42
44
case 'verify-full' :
43
45
return true
46
+ // no-verify is not standard to libpq but allows specifying
47
+ // you require ssl but want to bypass server certificate validation.
48
+ // this is a very common way to connect in heroku so we support it
49
+ // vai both environment variables (PGSSLMODE=no-verify) as well
50
+ // as in connection string params ?ssl=no-verify
44
51
case 'no-verify' :
45
52
return { rejectUnauthorized : false }
46
53
}
@@ -77,8 +84,8 @@ var ConnectionParameters = function (config) {
77
84
} )
78
85
79
86
this . binary = val ( 'binary' , config )
80
- // this.ssl = typeof config.ssl === 'undefined' ? useSsl() : config.ssl
81
- this . ssl = useSsl ( config . ssl )
87
+
88
+ this . ssl = normalizeSSLConfig ( config . ssl )
82
89
this . client_encoding = val ( 'client_encoding' , config )
83
90
this . replication = val ( 'replication' , config )
84
91
// a domain socket begins with '/'
0 commit comments