`sslmode=prefere` surface misleading "no encryption" error when using a wrong password
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
Comienza reproduciendo el fallo contra un servidor PostgreSQL que requiera SSL con una contraseña incorrecta y, después, inspecciona _connect_addr/__connect_addr y el manejo de los reintentos en connect_utils.py. Se considera terminado cuando se conserva el primer fallo de autenticación o el reintento deja de reemplazarlo por el engañoso error "no encryption".
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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?
- Lenguaje dominante
- Python
- Estrellas
- 8.1k
- Forks
- 469
- Merge medio
- 2 d 20 h
- PR fusionados (30 d)
- 9
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de MagicStack/asyncpg
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
MagicStack/asyncpg#1357 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
MagicStack/asyncpg#1354 ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
MagicStack/asyncpg#1342 ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 56/100
MagicStack/asyncpg#1340 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 28/100
MagicStack/asyncpg#1337 ·
Todos los issues de MagicStack/asyncpg
Issues similares
-
essnmx good first issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100
-
[Feature] 奇物选择添加优先级 Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
syfoud/Simulated_Scepter#174 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Giskard-AI/giskard-oss#2840 · 1 comentario ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Abiertoarea: repo bug perceived difficulty: 2
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
yeti-platform/yeti#1380 ·