From 877f7312c2a0764da6b65c450ace62b816a5c5cb Mon Sep 17 00:00:00 2001 From: Charles McGarvey Date: Wed, 14 Feb 2018 09:18:05 -0700 Subject: [PATCH] improve error message for private key not found --- lib/App/GroupSecret/File.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/App/GroupSecret/File.pm b/lib/App/GroupSecret/File.pm index 956b6f9..0cc42e8 100644 --- a/lib/App/GroupSecret/File.pm +++ b/lib/App/GroupSecret/File.pm @@ -290,6 +290,8 @@ sub decrypt_secret_passphrase { my $self = shift; my $private_key = shift or _usage(q{$file->decrypt_secret_passphrase($private_key)}); + die "Private key '$private_key' not found.\n" unless -e $private_key && !-d $private_key; + my $info = read_openssh_key_fingerprint($private_key); my $fingerprint = $info->{fingerprint}; @@ -298,7 +300,7 @@ sub decrypt_secret_passphrase { return decrypt_rsa(\$key->{secret_passphrase}, $private_key); } - die "The private key ($private_key) is not able to decrypt the keyfile.\n"; + die "Private key '$private_key' not able to decrypt the keyfile.\n"; } =method encrypt_secret -- 2.45.2