File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change 11import { logger } from '@internal/monitoring'
2+ import { ConnectionOptions } from 'tls'
23
34export function getSslSettings ( {
45 connectionString,
56 databaseSSLRootCert,
67} : {
78 connectionString : string
89 databaseSSLRootCert : string | undefined
9- } ) : { ca : string } | undefined {
10+ } ) : ConnectionOptions | undefined {
1011 if ( ! databaseSSLRootCert ) return undefined
1112
1213 try {
@@ -15,7 +16,7 @@ export function getSslSettings({
1516 // in case the hostname is an IP address
1617 const url = new URL ( connectionString )
1718 if ( url . hostname && isIpAddress ( url . hostname ) ) {
18- return undefined
19+ return { ca : databaseSSLRootCert , rejectUnauthorized : false }
1920 }
2021 } catch ( err ) {
2122 // ignore to ensure this never breaks the connection in case of an invalid URL
Original file line number Diff line number Diff line change @@ -23,13 +23,13 @@ describe('database utils', () => {
2323 ) . toBeUndefined ( )
2424 } )
2525
26- test ( 'should return no SSL settings if hostname is an IP address' , ( ) => {
26+ test ( 'should return SSL settings if hostname is an IP address' , ( ) => {
2727 expect (
2828 getSslSettings ( {
2929 connectionString :
'postgres://foo:[email protected] :5432/postgres' , 3030 databaseSSLRootCert : '<cert>' ,
3131 } )
32- ) . toBeUndefined ( )
32+ ) . toStrictEqual ( { ca : '<cert>' , rejectUnauthorized : false } )
3333 } )
3434
3535 test ( 'should return SSL settings if hostname is not an IP address' , ( ) => {
You can’t perform that action at this time.
0 commit comments