Page COW
Page COW

Reputation: 755

DeprecationWarning: Implicit disabling of certificate... How to fix? (node.js, express, massive)

I'm using Postgresql with Node.js, Express, and Massive. I'm getting this error:

"(node:11507) DeprecationWarning: Implicit disabling of certificate verification is deprecated and will be removed in pg 8. Specify rejectUnauthorized: true to require a valid CA or rejectUnauthorized: false to explicitly opt out of MITM protection."

My database connection string is set up with ?ssl=true at the end of the string. I think the error is saying that that configuration is deprecated. I've tried taking it out and adding this to my server:

require('dotenv').config();
const express = require('express');
const massive = require('massive');
const {CONNECTION_STRING} = process.env;

app.use(express.json());

CONNECTION_STRING.ssl = {
    rejectUnauthorized: true,
}

massive(CONNECTION_STRING).then(db => {
    app.set('db', db);
    console.log('db connected')
});

I still get errors. What's the correct way to configure this to make the error go away? I've been reading you need to configure it with .ssl = { rejectUnauthorized: true}. How exactly should I be writing the code? Can someone write out an example? And should the ?ssl-true be removed from the end of the db connection string?

Upvotes: 1

Views: 2745

Answers (0)

Related Questions