28 lines
465 B
Go
28 lines
465 B
Go
package git
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/ProtonMail/go-crypto/openpgp"
|
|
"github.com/ProtonMail/go-crypto/openpgp/armor"
|
|
)
|
|
|
|
func getSigner(keyFile string) (*openpgp.Entity, error) {
|
|
file, err := os.Open(keyFile)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer file.Close()
|
|
|
|
block, err := armor.Decode(file)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
entityList, err := openpgp.ReadKeyRing(block.Body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return entityList[0], nil
|
|
}
|