Deno / Postgres "invalid peer certificate contents: invalid peer certificate" error
Asked Answered
T

1

8

I'm using deno db to connect to a supabase postgres server.

Here's the error from deno deploy.

TLS connection failed with message: invalid peer certificate contents: invalid peer certificate: UnsupportedCertVersion Defaulting to non-encrypted connection

enter image description here

Establishing connection here:

import { Database, PostgresConnector } from "https://deno.land/x/denodb/mod.ts";
import "https://deno.land/x/dotenv/load.ts";

export const connection = (() => {
  const DENODB_PGURL = Deno.env.get('DENODB_PGURL');

  if (DENODB_PGURL) {
    return new PostgresConnector({uri: DENODB_PGURL});  
  }

  const DENODB_HOST = Deno.env.get('DENODB_HOST');
  if (!DENODB_HOST) throw new Error('DENODB_HOST is not set');
  const DENODB_USERNAME = Deno.env.get('DENODB_USERNAME');
  if (!DENODB_USERNAME) throw new Error('DENODB_USERNAME is not set');
  const DENODB_PASSWORD = Deno.env.get('DENODB_HOST');
  if (!DENODB_PASSWORD) throw new Error('DENODB_PASSWORD is not set');
  const DENODB_DATABASE = Deno.env.get('DENODB_DATABASE');
  if (!DENODB_DATABASE) throw new Error('DENODB_DATABASE is not set');
  
  return new PostgresConnector({
    host: DENODB_HOST,
    username: DENODB_USERNAME,
    password: DENODB_PASSWORD,
    database: DENODB_DATABASE,
  });

})()

const db = new Database(connection);

export default db;

I'm issuing a .create call later in the code.

To be clear the connection works and records are being created πŸ’―

Tall answered 26/8, 2022 at 6:2 Comment(5)
That looks like the error from the client side. Look in the db server's log fie to see how it experiences this error. Also, what version of the database is this? – Kacykaczer
Maybe you have already tried this, but have you tried updating your Supabase CLI to the most recent version? – Isothere
@Isothere this is happening on deno deploy not using the subpabase cli :) – Tall
Not sure, but might be related to this Deno issue: github.com/denoland/deno/issues/13350 – Pliner
Can you share an minimal reproducible example of a function that is failing? – Lemming
S
1

through this doc: https://deno.com/blog/v1.13

you can try deno run --unsafely-ignore-certificate-errors ...

enter image description here

Seek answered 15/12, 2023 at 7:58 Comment(1)
Just consider it makes TLS pointless because it allows MITM attacks – Gualtiero

© 2022 - 2024 β€” McMap. All rights reserved.