Error: self-signed certificate in certificate chain

getting the above error. heres my code:
import { betterAuth } from "better-auth";
import { Pool } from "pg";

import './envConfig'

export const auth = betterAuth({
database: new Pool({
connectionString: process.env.CONNECTION_STRING,
ssl: {
rejectUnauthorized: false
}
})
})
import { betterAuth } from "better-auth";
import { Pool } from "pg";

import './envConfig'

export const auth = betterAuth({
database: new Pool({
connectionString: process.env.CONNECTION_STRING,
ssl: {
rejectUnauthorized: false
}
})
})
i already added sslmode=require and rejectedUnaurhotized at the end of connection string as well
1 Reply
momoneko
momoneko5mo ago
The machine your code is running on likely does not trust the certificates the database is providing. You need to install the CA cert that signed the DB certs on your machine or provide a path to the same CA cert in your connection options. See the ca field in https://haxefoundation.github.io/hxnodejs/js/node/tls/SecureContextOptions.html How get the CA certs depends on how your DB is configured.

Did you find this page helpful?