Comments (5)
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.
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.
Any idea how to fix it? I get an error with ?sslmode=require
➡ Error: 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.
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.
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)
- Foreign key constraint name defaults to the name of the column
- Serialized Model option rather than classes?
- Can't import the latest version 1.0.40 HOT 5
- How to use denodb to connect to multiple postgresql databases having same models
- [Feature] Support SQL `SELECT DISTINCT`
- insert or update
- hash module break! HOT 4
- sqlite v3.1.3 not working on Windows
- Postgres Foreign Key is created with integer type by default HOT 2
- Timestamps
- Postgres connector makes the script unable to exit normally HOT 1
- How to set logging? HOT 2
- Postgresql: Timestamp fields adding hours each time records are updated
- Multiple Primary Key Exists HOT 1
- Some problems in model.ts
- A dependency is broken HOT 15
- Module not found "https://deno.land/std/node/events.ts". HOT 6
- DenoDB Models' fields without Types?
- Conditional "OR" query
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from denodb.