Skip to content

Commit

Permalink
Use password prompt if available for open ssh private key
Browse files Browse the repository at this point in the history
  • Loading branch information
dopey committed Feb 1, 2022
1 parent e6a14ce commit 3c468c0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pemutil/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ func ParseOpenSSHPrivateKey(pemBytes []byte, opts ...Options) (crypto.PrivateKey
var password []byte
if len(ctx.password) > 0 {
password = ctx.password
} else if ctx.passwordPrompter != nil {
password, err = ctx.passwordPrompter(ctx.passwordPrompt)
if err != nil {
return nil, err
}
} else if PromptPassword != nil {
password, err = PromptPassword(fmt.Sprintf("Please enter the password to decrypt %s", ctx.filename))
if err != nil {
Expand Down

0 comments on commit 3c468c0

Please sign in to comment.