envchain icon indicating copy to clipboard operation
envchain copied to clipboard

Passing multiline values into `--set`

Open liamnichols opened this issue 1 year ago • 2 comments

Background

I want to use envchain within our mobile team to store the App Store Connect API key credentials, which consist of an issuer id, key id and .p8 key file.

For simplicity and security, we already hold the .p8 file contents in secrets on Bitrise and since we need to run some operations locally, it feels like it would be appropriate to do this as well using envchain.

Problem

The problem that I faced however was that I couldn't get the multiline string to work with envchain --set.

If i try pasting it, only the first line is accepted. I also tried something like the following:

$ cat /path/to/key.p8 | envchain --set asc APP_STORE_CONNECT_API_KEY_KEY

But the same issue, only the first line is written.

Workaround

I can open the Keychain Access app and paste the multiline string in there, but it would be great if this could be avoided.

I'm sorry that I can't open a Pull Request directly for this, I am not very good with C 😄

liamnichols avatar Jun 26 '23 15:06 liamnichols

I can open the Keychain Access app and paste the multiline string in there, but it would be great if this could be avoided.

Yes this is a current restriction and valid workaround to deal with multiline strings...

sorah avatar Jun 26 '23 15:06 sorah

Thanks for confirming @sorah! In the end I was able to use the security command directly to automate it a bit better:

$ security add-generic-password -c appl -D envchain -s envchain-asc -a APP_STORE_CONNECT_API_KEY_KEY -w "$(cat /path/to/AuthKey_FFFFFFFFFFF.p8)"

liamnichols avatar Jun 27 '23 08:06 liamnichols