r-lib / keyring

:closed_lock_with_key: Access the system credential store from R
https://keyring.r-lib.org/
Other
196 stars 28 forks source link

Keyring fails to return value when password changed with Windows Credentials Manager #56

Closed ronblum closed 6 years ago

ronblum commented 6 years ago

Issue found using RStudio.

System details

RStudio Edition : Desktop
RStudio Version : 1.2.637
OS Version      : Windows 10
R Version       : 3.4.4, 3.5.0

Steps to reproduce the problem

  1. Set a username/password: key_set_with_value("bobo", username = "bobo_username", password = "bobo_password")
  2. Retrieve the password: key_get("bobo", "bobo_username")
    • Result: password

      [1] "bobo_password"

  3. Update the password using the Credential Manager in the Control Panel
  4. Retrieve the password: key_get("bobo", "bobo_username")
    • Result: error

      Error in b_wincred_get(self, private, service, username, keyring) : Key contains embedded null bytes, use get_raw()

Describe the problem in detail

When a keyring password is updated in Windows, key_get() returns an error instead of the password.

Describe the behavior you expected

The updated password would be returned. key_get_raw() doesn't help, as it returns a different error:

> key_get_raw("bobo", "bobo_username") Error in b_wincred_get_raw(self, private, service, username = NULL, keyring = NULL) : could not find function "b_wincred_get_raw"

gaborcsardi commented 6 years ago

I am pretty sure that this is an UTF8/UTF16 encoding issue, and I think we can work around it.

gaborcsardi commented 6 years ago

Should be OK now. We should probably always use UTF-16, but switching to that now could cause compatibility issues.