chamber icon indicating copy to clipboard operation
chamber copied to clipboard

Chamber fails to list, read or write secrets when it is a private key

Open dawilliams opened this issue 8 years ago • 2 comments

I'm not sure if this is a bug or I'm going it wrong but I can't get chamber to read or write a secret when the value is a private key (-----BEGIN RSA PRIVATE KEY-----) etc... I can store these values in the GUI but chamber can't decrypt it.

chamber read david git_priv_key
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x14015ba]

goroutine 1 [running]:
github.com/segmentio/chamber/store.parameterMetaToSecretMeta(0xc4203482c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/private/tmp/chamber-20171206-23249-ulm2p7/chamber-1.13.0/src/github.com/segmentio/chamber/store/ssmstore.go:404 +0x4a
github.com/segmentio/chamber/store.(*SSMStore).readLatest(0xc4200dcfe0, 0x7fff5fbff6f5, 0x5, 0x7fff5fbff6fb, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/private/tmp/chamber-20171206-23249-ulm2p7/chamber-1.13.0/src/github.com/segmentio/chamber/store/ssmstore.go:243 +0x53e
github.com/segmentio/chamber/store.(*SSMStore).Read(0xc4200dcfe0, 0x7fff5fbff6f5, 0x5, 0x7fff5fbff6fb, 0xc, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0x0, ...)
/private/tmp/chamber-20171206-23249-ulm2p7/chamber-1.13.0/src/github.com/segmentio/chamber/store/ssmstore.go:118 +0xda
github.com/segmentio/chamber/cmd.read(0x18b19c0, 0xc4200dce80, 0x2, 0x2, 0x0, 0x0)
/private/tmp/chamber-20171206-23249-ulm2p7/chamber-1.13.0/src/github.com/segmentio/chamber/cmd/read.go:56 +0x183
github.com/segmentio/chamber/vendor/github.com/spf13/cobra.(*Command).execute(0x18b19c0, 0xc4200dce00, 0x2, 0x2, 0x18b19c0, 0xc4200dce00)
/private/tmp/chamber-20171206-23249-ulm2p7/chamber-1.13.0/src/github.com/segmentio/chamber/vendor/github.com/spf13/cobra/command.go:647 +0x3f1
github.com/segmentio/chamber/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x18b1be0, 0x0, 0x3a, 0x18b0f20)
/private/tmp/chamber-20171206-23249-ulm2p7/chamber-1.13.0/src/github.com/segmentio/chamber/vendor/github.com/spf13/cobra/command.go:726 +0x2fe
github.com/segmentio/chamber/vendor/github.com/spf13/cobra.(*Command).Execute(0x18b1be0, 0xc420105f30, 0x1456ade)
/private/tmp/chamber-20171206-23249-ulm2p7/chamber-1.13.0/src/github.com/segmentio/chamber/vendor/github.com/spf13/cobra/command.go:685 +0x2b
github.com/segmentio/chamber/cmd.Execute()
/private/tmp/chamber-20171206-23249-ulm2p7/chamber-1.13.0/src/github.com/segmentio/chamber/cmd/root.go:42 +0x31
main.main()
/private/tmp/chamber-20171206-23249-ulm2p7/chamber-1.13.0/src/github.com/segmentio/chamber/main.go:6 +0x20

dawilliams avatar Dec 22 '17 18:12 dawilliams

Ah, so this panic is actually to do with the way chamber expects secrets to be formatted. In particular, chamber assumes that the Description field of a secret in SSM is an integer value representing the version of the secret (chamber was written before SSM stored this metadata itself).

As a workaround, you should be able to read certs with chamber that you also wrote using chamber (we do this a lot internally). For writing to chamber, you may find it useful to use the stdin input, for example:

$ chamber write service key - < ./certfile

Then you should be able to read with

$ chamber read -q service key

Let me know if that works for you (and I will go ahead and fix that panic)

dfuentes avatar Dec 22 '17 18:12 dfuentes

@dfuentes Thank your for your quick reply! That worked! Merry Christmas

dawilliams avatar Dec 22 '17 21:12 dawilliams