node-postgres: Unknown authenticationOk message type
With postgres 10.1 and SCRAM-SHA-256 password encryption enabled, node-postgres driver throws the following error:
Error: Unknown authenticationOk message typeMessage { name: 'authenticationOk', length: 23 }
Not telling that encryption method is not supported or anything. It took a while to find out why my app is stopped working after i have changed the role name. I think there should be more verbose error for this case.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 15
- Comments: 19 (1 by maintainers)
I have same problem and worked around it by installing
pg-native
and settingNODE_PG_FORCE_NATIVE=1
environment variable.Hello, I have the same problem. after migrate postgres 9 to 10, the database switch to SCRAM-SHA-256 password encryption. but this pg_client is not compatible
first, change the postgresql.conf file : password_encryption = md5
and restart database. but not works …
lookup users password encryption whith superuser (postgres) : SELECT rolname, rolpassword FROM “pg_authid”;
if password start with “SCRAM-SHA-256” (and not “md5”), it’s too late, but not the end of world.
–> change all user with SCRAM-SHA-256 password for reset them : (always whith postgres superuser) : alter role xxxxx with password ‘yyyyy’; (with xxxxx is the username, and yyyyy the new password)
–> the password is now encrypted with md5 crypto : SELECT rolname, rolpassword FROM “pg_authid”; –> the password start with “md5”
and now, i can use this pg_client without this error
explanation : the size “23” is because he know password is encrypted with SCRAM-SHA-256, and change the auth message for ask SCRAM password, and it’s not implemented yet …
have fun !
With postgresql starting to move towards SASL authentication with the introduction of SCRAM-SHA-256, and the known vulnerabilities in MD5, I think it is important for all major postgresql libraries to be supporting this encryption.
It is already supported in the latest libpq versions, which I know @brianc has create some native node bindings for.
@charmander yes i saw it in my conf file but anytime I try to connect with my db it brings out authenticationok error.
@Afoxcute pg supports SCRAM-SHA-256 now (#1835), so you shouldn’t need any workarounds.
I’m open to pull requests for adding this authentication. I’ll likely get around to it eventually, when I need it in my own work, but if you need it sooner please submit a PR!