Allow clearing of key password in ChangePassphraseDialogFunc

Use an empty password to clear any existing password in the
private key file. If not empty, the requirement of minimum 8
characters is retained.

For PEM key file, an empty password will clear encryption on
the key. For pkcs12 files it will set an empty password.
As use of an empty password is the default first try in
OpenVPN.exe when reading pkcs12 file, this effectively leads
to the user not prompted for a private key password during
connection setup.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
pull/424/head
Selva Nair 4 years ago
parent 96d443a9d0
commit c15fb27570

@ -371,17 +371,18 @@ ChangePassphraseDialogFunc(HWND hwndDlg, UINT msg, WPARAM wParam, UNUSED LPARAM
break; break;
} }
/* Check minimum length of password */ /* Confirm if the new password is empty. */
if (NewPasswordLengh(hwndDlg) < MIN_PASSWORD_LEN) if (NewPasswordLengh(hwndDlg) == 0)
{ {
ShowLocalizedMsg(IDS_ERR_PWD_TO_SHORT, MIN_PASSWORD_LEN); if (ShowLocalizedMsgEx(MB_YESNO, _T(PACKAGE_NAME), IDS_NFO_EMPTY_PWD) == IDNO)
break; break;
} }
/* Else check minimum length of password */
/* Confirm if the new password is empty. */ else if (NewPasswordLengh(hwndDlg) < MIN_PASSWORD_LEN)
if (NewPasswordLengh(hwndDlg) == 0 {
&& ShowLocalizedMsgEx(MB_YESNO, _T(PACKAGE_NAME), IDS_NFO_EMPTY_PWD) == IDNO) ShowLocalizedMsg(IDS_ERR_PWD_TO_SHORT, MIN_PASSWORD_LEN);
break; break;
}
GetDlgItemText(hwndDlg, ID_TXT_KEYFILE, keyfile, _countof(keyfile) - 1); GetDlgItemText(hwndDlg, ID_TXT_KEYFILE, keyfile, _countof(keyfile) - 1);
keyfile_format=GetDlgItemInt(hwndDlg, ID_TXT_KEYFORMAT, &Translated, FALSE); keyfile_format=GetDlgItemInt(hwndDlg, ID_TXT_KEYFORMAT, &Translated, FALSE);

Loading…
Cancel
Save