`sslmode=prefere` surface misleading "no encryption" error when using a wrong password
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 35/100
Piste de recherche
Commencez par reproduire l’échec avec un serveur PostgreSQL qui exige SSL en utilisant un mot de passe incorrect, puis examinez _connect_addr/__connect_addr et la gestion des nouvelles tentatives dans connect_utils.py. C’est terminé lorsque la première erreur d’authentification est conservée ou que la nouvelle tentative ne la remplace plus par l’erreur trompeuse "no encryption".
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Summary
When connecting with the default sslmode=prefere to a PostreSQL server that requires SSL (e.g. Amazon RDS with their default force_ssl=1), asyncpg reports:
asyncpg.exceptions.InvalidAuthorizationSpecificationError:
no pg_hba.conf entry for host "...", user "...", database "...", no encryption
The "no encryption" message points at an SSL/pg_hba.conf problem, when the actual issue is simply wrong credentials. This can send users on a lengthy debugging detour (so I heard).
Steps to reproduce
- Set up a PostgreSQL instance that requires SSL (e.g. Amazon RDS with
rds.force_ssl=1). - Attempt to connect with
sslmode=prefer(or rely on the default) using an incorrect password.
Expected: An error indicating password authentication failed (or at least something that points toward credentials). Actual: no pg_hba.conf entry ... no encryption
Analysis
(Disclaimer: First glance at the asyncpg code and no Python dev)
I believe what's happening is the following
The retry logic in _connect_addr / __connect_addr (connect_utils.py) does the following for sslmode=prefer:
- First attempt — connects with SSL. The TLS handshake succeeds, but authentication fails, raising
InvalidAuthorizationSpecificationError. The exact server message from this first attempt is never surfaced to the user. - The exception handler at the
except InvalidAuthorizationSpecificationErrorblock checksretry and params.sslmode == SSLMode.prefer and pr.is_ssl— allTrue— and raises_RetryConnectSignal. - Second attempt — connects without SSL. The server, which requires SSL, rejects the plaintext connection with the
pg_hba.conf/ "no encryption" error. This is the only error the user sees.
Is there a way to safely distinguish between both cases and do not attempt to retry when the first attempt fails because of a wrong password? Or otherwise: Can we preserve the error message and raise both?
- Langage dominant
- Python
- Étoiles
- 8.1k
- Forks
- 469
- Merge moyen
- 3 j 21 h
- PR mergées (30 j)
- 15
Préparer son environnement
Nous n'avons pas encore vérifié les fichiers d'installation de ce projet. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de MagicStack/asyncpg
-
Difficulté 3/5 1-2 jours Accessibilité débutants 72/100
MagicStack/asyncpg#1342 ·
-
Difficulté 3/5 1-2 jours Accessibilité débutants 56/100
MagicStack/asyncpg#1340 · 1 commentaire ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 28/100
MagicStack/asyncpg#1337 ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 42/100
MagicStack/asyncpg#1330 · 1 commentaire ·
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 38/100
MagicStack/asyncpg#1322 ·
Toutes les issues de MagicStack/asyncpg
Issues similaires
-
Broken links found in docsOuvertedocs pydanty:is-working
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
pydantic/pydantic-ai#8863 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
run-llama/llama_index#23278 ·
Les mainteneurs répondent en général sous 2 jours
-
documentation from-review-extraction github-actions priority: low severity:nit
Difficulté 1/5 Moins d'une heure Accessibilité débutants 92/100
LearningCircuit/local-deep-research#6946 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
oracle/langchain-oracle#323 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
tenstorrent/tt-metal#58057 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour