Skip to content

Commit 456faff

Browse files
committed
prompt for password within SSL-auto retry
Following the same flow for initial ERROR_CODE_ACCESS_DENIED, but with an ssl argument of None. This assumes that we always see HANDSHAKE_ERROR rather than ERROR_CODE_ACCESS_DENIED when both might apply.
1 parent 9323778 commit 456faff

File tree

2 files changed

+57
-21
lines changed

2 files changed

+57
-21
lines changed

changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
TBD
2+
==============
3+
4+
Bug Fixes
5+
--------
6+
* Prompt for password within SSL-auto retry flow.
7+
8+
19
1.43.0 (2026/01/02)
210
==============
311

mycli/main.py

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,8 @@ def _connect() -> None:
552552
ssh_key_filename,
553553
init_command,
554554
)
555-
except pymysql.OperationalError as e:
556-
if e.args[0] == ERROR_CODE_ACCESS_DENIED:
555+
except pymysql.OperationalError as e1:
556+
if e1.args[0] == ERROR_CODE_ACCESS_DENIED:
557557
if password_from_file is not None:
558558
new_passwd = password_from_file
559559
else:
@@ -577,26 +577,54 @@ def _connect() -> None:
577577
ssh_key_filename,
578578
init_command,
579579
)
580-
elif e.args[0] == HANDSHAKE_ERROR and ssl is not None and ssl.get("mode", None) == "auto":
581-
self.sqlexecute = SQLExecute(
582-
database,
583-
user,
584-
passwd,
585-
host,
586-
int_port,
587-
socket,
588-
charset,
589-
use_local_infile,
590-
None,
591-
ssh_user,
592-
ssh_host,
593-
int(ssh_port) if ssh_port else None,
594-
ssh_password,
595-
ssh_key_filename,
596-
init_command,
597-
)
580+
elif e1.args[0] == HANDSHAKE_ERROR and ssl is not None and ssl.get("mode", None) == "auto":
581+
try:
582+
self.sqlexecute = SQLExecute(
583+
database,
584+
user,
585+
passwd,
586+
host,
587+
int_port,
588+
socket,
589+
charset,
590+
use_local_infile,
591+
None,
592+
ssh_user,
593+
ssh_host,
594+
int(ssh_port) if ssh_port else None,
595+
ssh_password,
596+
ssh_key_filename,
597+
init_command,
598+
)
599+
except pymysql.OperationalError as e2:
600+
if e2.args[0] == ERROR_CODE_ACCESS_DENIED:
601+
if password_from_file is not None:
602+
new_passwd = password_from_file
603+
else:
604+
new_passwd = click.prompt(
605+
f"Password for {user}", hide_input=True, show_default=False, default='', type=str, err=True
606+
)
607+
self.sqlexecute = SQLExecute(
608+
database,
609+
user,
610+
new_passwd,
611+
host,
612+
int_port,
613+
socket,
614+
charset,
615+
use_local_infile,
616+
None,
617+
ssh_user,
618+
ssh_host,
619+
int(ssh_port) if ssh_port else None,
620+
ssh_password,
621+
ssh_key_filename,
622+
init_command,
623+
)
624+
else:
625+
raise e2
598626
else:
599-
raise e
627+
raise e1
600628

601629
try:
602630
if not WIN and socket:

0 commit comments

Comments
 (0)