Skip to content

Commit 602a5c3

Browse files
committed
make WHISPER_DEFAULT_KEY and WHISPER_DEFAULT_KEY_PATH easier to use in CI
1 parent dfb83fe commit 602a5c3

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

constants.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"os"
55
)
66

7+
var WHISPER_DEFAULT_KEY_PATH = os.Getenv("WHISPER_DEFAULT_KEY_PATH")
8+
79
var WHISPER_DEFAULT_KEY = os.Getenv("WHISPER_DEFAULT_KEY")
810

911
var WHISPER_PASSPHRASE = os.Getenv("WHISPER_PASSPHRASE")

lib/whisper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
const (
15-
APIVersion = "v0.8.13"
15+
APIVersion = "v0.8.14"
1616
WireFormatVersion = byte(8)
1717
)
1818

main.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ func main() { //nolint: funlen,gocyclo,cyclop
4141
WHISPER_AGENT_ADDR = WHISPER_AGENT_ADDR_DEFAULT
4242
}
4343

44-
privateKey := flags.String("p", WHISPER_DEFAULT_KEY, "Private key path to decrypt data.\n"+
45-
"You can use env var WHISPER_DEFAULT_KEY to set the default key path.\n"+
44+
privateKey := flags.String("p", WHISPER_DEFAULT_KEY_PATH, "Private key path to decrypt data.\n"+
45+
"Use env var WHISPER_DEFAULT_KEY to set the default key data.\n"+
46+
"Use env var WHISPER_DEFAULT_KEY_PATH to set the default key path.\n"+
4647
"If it's empty a key in ~/.ssh will be auto selected.\n"+
4748
"If it requires a passphrase, env var WHISPER_PASSPHRASE will be used or a password cli prompt will show up.\n"+
4849
"The file path should always use / as the separator, even on Windows.")
@@ -192,6 +193,15 @@ func getPrivate(decrypt bool, sign bool, location string, meta *whisper.Meta) *w
192193
return nil
193194
}
194195

196+
if location == "" && WHISPER_DEFAULT_KEY != "" {
197+
private := whisper.PrivateKey{
198+
Data: []byte(WHISPER_DEFAULT_KEY),
199+
Passphrase: WHISPER_PASSPHRASE,
200+
}
201+
202+
return ensurePassphrase(private, location)
203+
}
204+
195205
if location == "" && decrypt {
196206
location = findPrivateKey(meta)
197207
}
@@ -245,7 +255,7 @@ func findPrivateKey(meta *whisper.Meta) string {
245255
return p
246256
}
247257

248-
return WHISPER_DEFAULT_KEY
258+
return WHISPER_DEFAULT_KEY_PATH
249259
}
250260

251261
func getPublicKeys(paths []string) []whisper.PublicKey {

0 commit comments

Comments
 (0)