Use safer approach for passphrase handling
-
Use a dedicated
Passphrase
type which wrapssecrecy::SecretString
, so that passphrases can be handled safely and only be passed as plainString
when really required. -
Introduce a
Credentials
type which carries a user ID and passphrase for API connections. -
Defer the creation of the connection
Configuration
to right before when it is used, so thatCredentials
are only ever passed in at that point in time. This prevents thePassphrase
from being turned into aString
for the lifetime of theNetHsm
. Consequently we are now storing all availableCredentials
in aHashMap
and refer to the currentCredentials
byString
(matching a key in theHashMap
). The requiredAgent
andUrl
are now also members of theNetHsm
struct and the latter can be set using theNetHsm::set_url
function. -
As a drive-by change the
NetHsm::set_url
function now takes anethsm::Url
instead of aString
. -
Instead of using stacked fixtures for the containers and accompanying
NetHsm
instances, use dedicated fixtures. This prevents containers hanging during tests, as theNetHsm
reuses the same connection properties if more than one container is used per test.