question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support scram-sha-256 authentication

See original GitHub issue

As soon as I attempt a Client.connect I am having this error:

error: Uncaught Error: Unknown auth message code 10
        throw new Error('Unknown auth message code ${code}');
              ^
    at Connection.handleAuth (https://deno.land/x/postgres@v0.4.5/connection.ts:197:15)
    at Connection.startup (https://deno.land/x/postgres@v0.4.5/connection.ts:155:16)
    at async Client.connect (https://deno.land/x/postgres@v0.4.5/client.ts:14:5)

my client instantiation:

const client = new Client({
    user: 'postgres',
    password: 'postgres',
    database: 'test',
    hostname: 'localhost',
    port: 5432,
})

The permissions at launch deno run --no-check --unstable --allow-net --allow-env --allow-read app.ts --local

The service is obviously running and I can access the database through other means with the same credentials.

Edit: It would seems like i am able to connect to a remote database, but not the local one.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:15 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
EliSaudercommented, Nov 7, 2020

The error is related to supported encryption types. Newer versions of postgresql use scram-sha-256 for authentication. However, it appears that this driver only supports md5 encryption. To use new versions you will have to manually enter in a md5 hash for your postgres user’s password. How to generate md5 authentication for postgres: https://stackoverflow.com/a/58979721 Once you have the hash you can do:

ALTER USER username WITH ENCRYPTED PASSWORD 'md5yourmd5hashhere';

This driver should be updated to use the newer authentication as it is more secure.

1reaction
Soremwarcommented, Apr 3, 2021

Thanks to the effort of @snsinfu this is now supported, you can take it for a ride before the 0.9.0 release by importing from https://raw.githubusercontent.com/denodrivers/postgres/master/mod.ts

Closed in #267

Read more comments on GitHub >

github_iconTop Results From Across the Web

To scram-sha-256 from MD5 in PostgreSQL- CYBERTEC
This article explains in simple steps how to improve security in PostgreSQL by converting from MD5 hashes to scram-sha-256.
Read more >
SASL/SCRAM-SHA-256 Secure Password-based Authentication
This page provides an overview of the security and implementation considerations for using SCRAM-SHA-256 authentication in CockroachDB. CockroachDB supports ...
Read more >
SCRAM — MongoDB Manual
When you use SCRAM-SHA-256 , MongoDB requires server-side password hashing, which means that the server digests the password. For more information, see db....
Read more >
PostgreSQL - password authentication to SCRAM-SHA-256.
Change PostgreSQL Password Authentication to SCRAM-SHA-256. By default (out-of-the-box installation), Postgres uses md5 encryption.
Read more >
Configuring the SCRAM-SHA-256 authentication
To configure the SCRAM-SHA-256 authentication · Navigate to the path where the file is available. Example path: /var/lib/pgsql/12/data/postgresql ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found