mirror of https://github.com/docker/docs.git
make touch to sign message configurable
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
This commit is contained in:
parent
15154384cd
commit
b0354762d1
|
@ -56,6 +56,25 @@ func SetYubikeyKeyMode(keyMode int) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetTouchToSignUI - allows configurable UX for notifying a user that they
|
||||||
|
// need to touch the yubikey to sign. The callback may be used to provide a
|
||||||
|
// mechanism for updating a GUI (such as removing a modal) after the touch
|
||||||
|
// has been made
|
||||||
|
func SetTouchToSignUI(notifier func(), callback func()) {
|
||||||
|
touchToSignUI = notifier
|
||||||
|
if callback != nil {
|
||||||
|
touchDoneCallback = callback
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var touchToSignUI = func() {
|
||||||
|
fmt.Println("Please touch the attached Yubikey to perform signing.")
|
||||||
|
}
|
||||||
|
|
||||||
|
var touchDoneCallback = func() {
|
||||||
|
// noop
|
||||||
|
}
|
||||||
|
|
||||||
var pkcs11Lib string
|
var pkcs11Lib string
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -324,7 +343,8 @@ func sign(ctx *pkcs11.Ctx, session pkcs11.SessionHandle, pkcs11KeyID []byte, pas
|
||||||
// Get the SHA256 of the payload
|
// Get the SHA256 of the payload
|
||||||
digest := sha256.Sum256(payload)
|
digest := sha256.Sum256(payload)
|
||||||
|
|
||||||
fmt.Println("Please touch the attached Yubikey to perform signing.")
|
touchToSignUI()
|
||||||
|
defer touchDoneCallback()
|
||||||
sig, err = ctx.Sign(session, digest[:])
|
sig, err = ctx.Sign(session, digest[:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Debugf("Error while signing: %s", err)
|
logrus.Debugf("Error while signing: %s", err)
|
||||||
|
|
Loading…
Reference in New Issue