Giter VIP home page Giter VIP logo

Comments (5)

reggi avatar reggi commented on September 25, 2024 1

I added ?sslmode=require to the end of the connection uri and I'm getting a new error:

An error occurred during route handling or page rendering. Error: The certificate used to secure the TLS connection is invalid.
    at Connection.#startup (https://deno.land/x/[email protected]/connection/connection.ts:238:31)
    at async Connection.startup (https://deno.land/x/[email protected]/connection/connection.ts:311:21)
    at async Client.connect (https://deno.land/x/[email protected]/client.ts:131:13)
    at async PostgresConnector._makeConnection (https://deno.land/x/[email protected]/lib/connectors/postgres-connector.ts:28:9)
    at async PostgresConnector.query (https://deno.land/x/[email protected]/lib/connectors/postgres-connector.ts:42:9)
    at async Database.query (https://deno.land/x/[email protected]/lib/database.ts:117:25)
    at async Function._runQuery (https://deno.land/x/[email protected]/lib/model.ts:78:25)
    at async Function.create (https://deno.land/x/[email protected]/lib/model.ts:212:25)
    at async endpoint (file:///src/calendar/denodb/endpoint.ts:6:5)
    at async Object.handler (file:///src/calendar/denodb/fresh/api.ts:4:25)

from denodb.

heqian avatar heqian commented on September 25, 2024

I encountered the same initial issue with my project:

Dec 5 10:35:00 PM  TLS connection failed with message: Bad resource ID
Dec 5 10:35:00 PM  Defaulting to non-encrypted connection
Dec 5 10:35:00 PM  PostgresError: SSL/TLS required
Dec 5 10:35:00 PM      at assertSuccessfulStartup (https://deno.land/x/[email protected]/connection/connection.ts:68:13)
Dec 5 10:35:00 PM      at Connection.#startup (https://deno.land/x/[email protected]/connection/connection.ts:350:7)
Dec 5 10:35:00 PM      at async Connection.startup (https://deno.land/x/[email protected]/connection/connection.ts:417:11)
Dec 5 10:35:00 PM      at async Connection.query (https://deno.land/x/[email protected]/connection/connection.ts:869:7)
Dec 5 10:35:00 PM      at async PostgresConnector.query (https://deno.land/x/[email protected]/lib/connectors/postgres-connector.ts:76:22)
Dec 5 10:35:00 PM      at async Database.query (https://deno.land/x/[email protected]/lib/database.ts:240:21)
Dec 5 10:35:00 PM      at async Function._runQuery (https://deno.land/x/[email protected]/lib/model.ts:228:21)
Dec 5 10:35:00 PM      at async Function.first (https://deno.land/x/[email protected]/lib/model.ts:550:21)

and same error after adding ?sslmode=require.

I'm using PostgreSQL 15. Maybe it is a compatibility issue?

from denodb.

kaldaf avatar kaldaf commented on September 25, 2024

Any idea how to fix it? I get an error with ?sslmode=requireError: the certificate used to secure the TLS connection is invalid. and Sending fatal alert BadCertificate

  • deno 1.30.3 (release, x86_64-pc-windows-msvc)
  • v8 10.9.194.5
  • typescript 4.9.4

from denodb.

pankgeorg avatar pankgeorg commented on September 25, 2024

Coming to this issue from googling Error: the certificate used to secure the TLS connection is invalid. and Sending fatal alert BadCertificate.

IT seems that deno doesn't load certificates correctly, or doesn't have the default debian certificates or something.

In deno-deploy, I solved this by adding an environment variable with the certificate found in /etc/postgresql/15/main/postgresql.conf: ssl_cert_file, which, in my case is cat /etc/ssl/certs/ssl-cert-snakeoil.pem. In deno, do:

const cert = Deno.env.get("CERTIFICATE")

and then to the client

const options = {
  database: "db",
  hostname: "myhost",
  password: Deno.env.get("POSTGRES_PASSWORD"),
  port: 5432,
  user: "deno",
  tls: {
    caCertificates: [
      certificate,
    ],
    enabled: false,
  },
}
const pool = new Pool(options, 5, true);

this should work!

from denodb.

jeremyjh avatar jeremyjh commented on September 25, 2024

OP is using Heroku, which uses self-signed certificates by default. They do have a feature for CA-signed certificates in preview. https://devcenter.heroku.com/articles/heroku-postgres-enhanced-certificates

from denodb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.