Remove responsibility for credentials mutex locking from external
callers and handle appropriate locks internally. This allows the
mutex lock to be much "tighter" and avoids deadlocks when
credentials are requested while an existing credentials dialog
is being shown.
(No mutex is required protecting the credentials dialog itself
as this is ALWAYS shown in the main thread)
Fixes#20826