func (k *KeyringFile) Load() error { k.G().Log.Debug(fmt.Sprintf("+ Loading PGP Keyring %s", k.filename)) file, err := os.Open(k.filename) if os.IsNotExist(err) { G.Log.Warning(fmt.Sprintf("No PGP Keyring found at %s", k.filename)) err = nil } else if err != nil { G.Log.Errorf("Cannot open keyring %s: %s\n", k.filename, err) return err } if file != nil { k.Entities, err = openpgp.ReadKeyRing(file) if err != nil { G.Log.Errorf("Cannot parse keyring %s: %s\n", k.filename, err) return err } } k.G().Log.Debug(fmt.Sprintf("- Successfully loaded PGP Keyring")) return nil }
func ReadOneKeyFromBytes(b []byte) (*PGPKeyBundle, error) { reader := bytes.NewBuffer(b) el, err := openpgp.ReadKeyRing(reader) return finishReadOne(el, "", err) }