@@ -25,9 +25,11 @@ var val = function (key, config, envVar) {
2525 return config [ key ] || envVar || defaults [ key ]
2626}
2727
28- var useSsl = function ( modeFromConfig ) {
28+ var normalizeSSLConfig = function ( modeFromConfig ) {
2929 // if the ssl parameter passed to config is not a string, just return it
3030 // 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
3133 if ( modeFromConfig !== undefined && typeof modeFromConfig !== 'string' ) {
3234 return modeFromConfig
3335 }
@@ -41,6 +43,11 @@ var useSsl = function (modeFromConfig) {
4143 case 'verify-ca' :
4244 case 'verify-full' :
4345 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
4451 case 'no-verify' :
4552 return { rejectUnauthorized : false }
4653 }
@@ -77,8 +84,8 @@ var ConnectionParameters = function (config) {
7784 } )
7885
7986 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 )
8289 this . client_encoding = val ( 'client_encoding' , config )
8390 this . replication = val ( 'replication' , config )
8491 // a domain socket begins with '/'
0 commit comments