MCPcopy Create free account
hub / github.com/LanceLRQ/deer-executor / GetPublicKeyArmorBytes

Function GetPublicKeyArmorBytes

common/persistence/utils.go:180–204  ·  view source on GitHub ↗

GetPublicKeyArmorBytes 读取GPG证书信息

(entity *openpgp.Entity)

Source from the content-addressed store, hash-verified

178
179// GetPublicKeyArmorBytes 读取GPG证书信息
180func GetPublicKeyArmorBytes(entity *openpgp.Entity) ([]byte, error) {
181 pathname := path.Join("/tmp/" + uuid.NewV4().String() + ".key")
182 fp, err := os.Create(pathname)
183 if err != nil {
184 return nil, err
185 }
186 defer os.Remove(pathname)
187
188 w, err := armor.Encode(fp, openpgp.PublicKeyType, nil)
189 if err != nil {
190 return nil, err
191 }
192 err = entity.Serialize(w)
193 if err != nil {
194 return nil, err
195 }
196 _ = w.Close()
197 _ = fp.Close()
198
199 data, err := ioutil.ReadFile(pathname)
200 if err != nil {
201 return nil, err
202 }
203 return data, nil
204}
205
206// GetArmorPublicKey 从文件读取GPG证书公钥信息
207func GetArmorPublicKey(gpgKeyFile string, passphrase []byte) (*DigitalSignPEM, error) {

Callers 1

GetArmorPublicKeyFunction · 0.85

Calls 1

StringMethod · 0.65

Tested by

no test coverage detected