func LoadKeyring(path string) (openpgp.EntityList, error) { if path == "" { return nil, util.Errorf("no keyring configured") } f, err := os.Open(path) if err != nil { return nil, err } defer f.Close() // Accept both ASCII-armored and binary encodings keyring, err := openpgp.ReadArmoredKeyRing(f) if err != nil && err.Error() == "openpgp: invalid argument: no armored data found" { offset, seekErr := f.Seek(0, os.SEEK_SET) if offset != 0 || seekErr != nil { return nil, util.Errorf( "couldn't seek to beginning, got %d %s", offset, seekErr, ) } keyring, err = openpgp.ReadKeyRing(f) } return keyring, err }
func (h *testHarness) loadEntities() []*openpgp.Entity { if h.Err != nil { return nil } keyring, err := openpgp.ReadArmoredKeyRing(strings.NewReader(testUsers)) if err != nil { h.Err = err return nil } return keyring }