Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while encrypting the text provided to safeStorage.encryptString. Encryption is not available. #188059

Closed
wilhelmklopp opened this issue Jul 17, 2023 · 10 comments · Fixed by #188692
Assignees
Labels
authentication Issues with the Authentication platform bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Milestone

Comments

@wilhelmklopp
Copy link

wilhelmklopp commented Jul 17, 2023

From version 1.80 onwards, we've been getting CI failures when testing our vscode extension with this error message: "Error while encrypting the text provided to safeStorage.encryptString. Encryption is not available."

I suspect this is related to the move off keytar described in the release notes of 1.80 and here microsoft/vscode-discussions#662

For the purposes of testing our extension, we pass additional launchArgs to VSCode, notably --disable-keytar. As I understand it, this instructs VSCode to use some sort of in memory keytar so that the secrets are not actually persisted to disk? This is the desired behaviour for us so that no secrets persist after the the test suite concludes. This has been working well until now, and based on a quick search for --disable-keytar on GitHub, it seems like a popular approach when testing VSCode extensions.

Notably this only seems to happen in our linux CI. Mac and Windows continue to work without a problem (as also demonstrated below)


Does this issue occur when all extensions are disabled?: Yes

Steps to Reproduce:

I've created a minimal repro here: https://github.com/kolofordjango/encryption-not-available-demo

The line that ends up resulting in the error: https://github.com/kolofordjango/encryption-not-available-demo/blob/efe774347bf9027e4f81c1ecf88bfaba617ecd78/src/test/suite/extension.test.ts#L21

GitHub Actions Build showing the error: https://github.com/kolofordjango/encryption-not-available-demo/actions/runs/5575232697/jobs/10184874439#step:5:82

PR demonstrating no errors happened on 1.79.2: kolofordjango/encryption-not-available-demo#1

@TylerLeonhardt
Copy link
Member

TylerLeonhardt commented Jul 17, 2023

When encryption isn't available, we use an in-memory store instead so I think the current behavior should give you the desired behavior, no? Or does it actually throw instead and cause the extension to not function?

@TylerLeonhardt TylerLeonhardt added the info-needed Issue requires more information from poster label Jul 17, 2023
@wilhelmklopp
Copy link
Author

Or does it actually throw instead and cause the extension to not function?

@TylerLeonhardt Yeah exactly, it just throws right now (on linux). Same code works without issue on 1.79

@TylerLeonhardt
Copy link
Member

I think this is because you see a dialog in the product to ask you to do something. I need to make that dialog non-blocking.

In the meantime, you can do this:

https://code.visualstudio.com/docs/editor/settings-sync#_not-recommended-configure-basic-text-encryption

And configure basic text encryption which is fine because the container will be destroyed after.

@wilhelmklopp
Copy link
Author

Thanks!

I added --password-store="basic" to the launchArgs, but seem to be getting the same error: kolofordjango/encryption-not-available-demo#2

@TylerLeonhardt
Copy link
Member

I think maybe you want --password-store=basic not --password-store="basic". I just tried on my Ubuntu machine and --password-store=basic worked.

@TylerLeonhardt TylerLeonhardt added feature-request Request for new features or functionality authentication Issues with the Authentication platform and removed info-needed Issue requires more information from poster labels Jul 20, 2023
@TylerLeonhardt TylerLeonhardt added this to the Backlog milestone Jul 20, 2023
@TylerLeonhardt TylerLeonhardt added info-needed Issue requires more information from poster and removed feature-request Request for new features or functionality authentication Issues with the Authentication platform labels Jul 20, 2023
@TylerLeonhardt TylerLeonhardt removed this from the Backlog milestone Jul 20, 2023
@TylerLeonhardt
Copy link
Member

FYI I have opened #188432 to track allowing an in memory secret storage. If we get you unblocked with --password-store=basic I'll dupe this to that.

@wilhelmklopp
Copy link
Author

wilhelmklopp commented Jul 24, 2023

@TylerLeonhardt thanks for continuing to look into this!

I applied your suggestion (--password-store=basic without the quotes) but looks like on GitHub Actions (ubuntu) it still results in the same issue: kolofordjango/encryption-not-available-demo@9e3950d

1) Extension Test Suite
       Sample test:
     Error: Error while encrypting the text provided to safeStorage.encryptString. Encryption is not available.
      at D.encrypt (.vscode-test/vscode-linux-x64-insiders/resources/app/out/vs/code/electron-main/main.js:42:10999)
      at Object.call (.vscode-test/vscode-linux-x64-insiders/resources/app/out/vs/code/electron-main/main.js:25:4[84](https://github.com/kolofordjango/encryption-not-available-demo/actions/runs/5643517876/job/15285522193#step:5:85)4)
      at S.s (.vscode-test/vscode-linux-x64-insiders/resources/app/out/vs/code/electron-main/main.js:23:5128)
      at S.q (.vscode-test/vscode-linux-x64-insiders/resources/app/out/vs/code/electron-main/main.js:23:4644)
      at o.value (.vscode-test/vscode-linux-x64-insiders/resources/app/out/vs/code/electron-main/main.js:23:4051)
      at b.w (.vscode-test/vscode-linux-x64-insiders/resources/app/out/vs/code/electron-main/main.js:18:1906)
      at b.x (.vscode-test/vscode-linux-x64-insiders/resources/app/out/vs/code/electron-main/main.js:18:1976)
      at b.fire (.vscode-test/vscode-linux-x64-insiders/resources/app/out/vs/code/electron-main/main.js:18:2192)
      at o.value (.vscode-test/vscode-linux-x64-insiders/resources/app/out/vs/code/electron-main/main.js:16:3[86](https://github.com/kolofordjango/encryption-not-available-demo/actions/runs/5643517876/job/15285522193#step:5:87)81)
      at b.w (.vscode-test/vscode-linux-x64-insiders/resources/app/out/vs/code/electron-main/main.js:18:1906)
      at b.fire (.vscode-test/vscode-linux-x64-insiders/resources/app/out/vs/code/electron-main/main.js:18:2123)
      at o.value (.vscode-test/vscode-linux-x64-insiders/resources/app/out/vs/code/electron-main/main.js:16:38[87](https://github.com/kolofordjango/encryption-not-available-demo/actions/runs/5643517876/job/15285522193#step:5:88)5)
      at b.w (.vscode-test/vscode-linux-x64-insiders/resources/app/out/vs/code/electron-main/main.js:18:1[90](https://github.com/kolofordjango/encryption-not-available-demo/actions/runs/5643517876/job/15285522193#step:5:91)6)
      at b.fire (.vscode-test/vscode-linux-x64-insiders/resources/app/out/vs/code/electron-main/main.js:18:2123)
      at se (.vscode-test/vscode-linux-x64-insiders/resources/app/out/vs/code/electron-main/main.js:16:41018)
      at IpcMainImpl.f (.vscode-test/vscode-linux-x64-insiders/resources/app/out/vs/code/electron-main/main.js:19:[96](https://github.com/kolofordjango/encryption-not-available-demo/actions/runs/5643517876/job/15285522193#step:5:97)358)
      at IpcMainImpl.emit (node:events:513:28)
      at EventEmitter.<anonymous> (node:electron/js2c/browser_init:2:80[97](https://github.com/kolofordjango/encryption-not-available-demo/actions/runs/5643517876/job/15285522193#step:5:98)9)
      at EventEmitter.emit (node:events:513:28)

Error: 1 tests failed.
	at /home/runner/work/encryption-not-available-demo/encryption-not-available-demo/out/test/suite/index.js:25:27
	at done (/home/runner/work/encryption-not-available-demo/encryption-not-available-demo/node_modules/mocha/lib/mocha.js:[101](https://github.com/kolofordjango/encryption-not-available-demo/actions/runs/5643517876/job/15285522193#step:5:102)2:7)
[main 2023-07-24T10:06:50.284Z] Extension host with pid 2055 exited with code: 0, signal: unknown.

@deepak1556
Copy link
Collaborator

@TylerLeonhardt it should be basic instead of basic_text in https://github.com/microsoft/vscode/blob/dad3c697b0e4f55b32fd0a831840db6ca8eef03b/src/vs/platform/encryption/electron-main/encryptionMainService.ts#L28C1-L30, without that setUsePlainTextEncryption will not be called and causes the above error to be thrown.

@wilhelmklopp
Copy link
Author

Setting --password-store=basic_text seems to do the trick for me 🎉 – thank you!

kolofordjango/encryption-not-available-demo@69d60b5

@TylerLeonhardt
Copy link
Member

FYI, I will change it to be --password-store=basic to align with what Electron actually accepts.

TylerLeonhardt added a commit that referenced this issue Jul 24, 2023
TylerLeonhardt added a commit that referenced this issue Jul 24, 2023
* Use `basic` for `password-store`

Fixes #188059

* add to node argv.ts
@vscodenpa vscodenpa added the unreleased Patch has not yet been released in VS Code Insiders label Jul 24, 2023
@vscodenpa vscodenpa added this to the July 2023 milestone Jul 24, 2023
@vscodenpa vscodenpa added insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Jul 25, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Sep 7, 2023
@TylerLeonhardt TylerLeonhardt added bug Issue identified by VS Code Team member as probable bug verified Verification succeeded authentication Issues with the Authentication platform and removed info-needed Issue requires more information from poster labels Sep 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
authentication Issues with the Authentication platform bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants