本文整理汇总了Golang中github.com/keybase/client/go/libkb.PGPKeyBundle.GetFingerprint方法的典型用法代码示例。如果您正苦于以下问题:Golang PGPKeyBundle.GetFingerprint方法的具体用法?Golang PGPKeyBundle.GetFingerprint怎么用?Golang PGPKeyBundle.GetFingerprint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/keybase/client/go/libkb.PGPKeyBundle
的用法示例。
在下文中一共展示了PGPKeyBundle.GetFingerprint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: deviceSignPGP
func (d *Locksmith) deviceSignPGP(ctx *Context) (err error) {
d.G().Log.Debug("+ deviceSignPGP")
defer func() {
d.G().Log.Debug("- deviceSignPGP -> %s", libkb.ErrToOk(err))
}()
pgpKeys := d.arg.User.GetActivePGPKeys(false)
if len(pgpKeys) == 0 {
err = errors.New("no active PGP keys unexpectedly")
return err
}
var selected *libkb.PGPKeyBundle
if len(pgpKeys) > 1 {
// show a list of pgp keys and let them select which one to use
selected, err = d.selectPGPKey(ctx, pgpKeys)
if err != nil {
return err
}
if selected == nil {
err = fmt.Errorf("no key selected")
return err
}
} else {
selected = pgpKeys[0]
}
ctx.LogUI.Debug("selected pgp key: %s", selected.VerboseDescription())
ctx.LogUI.Debug("selected pgp key kid: %s", selected.GetKID())
var pk libkb.ServerPrivateKey
var ok bool
if ctx.LoginContext != nil {
pk, ok = ctx.LoginContext.SecretSyncer().FindPrivateKey(selected.GetKID().String())
} else {
err = d.G().LoginState().SecretSyncer(func(ss *libkb.SecretSyncer) {
pk, ok = ss.FindPrivateKey(selected.GetKID().String())
}, "Locksmith - deviceSignPGP - FindPrivateKey")
if err != nil {
return err
}
}
if ok {
d.G().Log.Debug("| found synced secret key, unlocking it")
skb, serr := pk.ToSKB(d.G())
if serr != nil {
err = serr
return err
}
pgpk, perr := skb.PromptAndUnlock(ctx.LoginContext, "sign new device", "keybase", nil, ctx.SecretUI, nil, d.arg.User)
if perr != nil {
err = perr
return err
}
return d.deviceSignPGPNext(ctx, pgpk)
}
// use gpg to unlock it
gpg := d.G().GetGpgClient()
if err = gpg.Configure(); err != nil {
return err
}
bundle, ierr := gpg.ImportKey(true, selected.GetFingerprint())
if ierr != nil {
err = ierr
return err
}
if err = bundle.Unlock("adding this device to your account", ctx.SecretUI); err != nil {
err = fmt.Errorf("bundle Unlock error: %s", err)
return err
}
return d.deviceSignPGPNext(ctx, bundle)
}