jsonsign: make sure armored public key ends in a newline

Change-Id: Ia0e52c6e011db295c21eb8b1b6b6534873bf6310
This commit is contained in:
Brad Fitzpatrick 2011-12-07 14:39:40 -08:00
parent 38d138c2dc
commit a16b1f43ca
1 changed files with 5 additions and 0 deletions

View File

@ -113,6 +113,8 @@ func EntityFromSecring(keyId, keyFile string) (*openpgp.Entity, os.Error) {
return entity, nil
}
var newlineBytes = []byte("\n")
func ArmoredPublicKey(entity *openpgp.Entity) (string, os.Error) {
var buf bytes.Buffer
wc, err := armor.Encode(&buf, openpgp.PublicKeyType, nil)
@ -124,5 +126,8 @@ func ArmoredPublicKey(entity *openpgp.Entity) (string, os.Error) {
return "", err
}
wc.Close()
if !bytes.HasSuffix(buf.Bytes(), newlineBytes) {
buf.WriteString("\n")
}
return buf.String(), nil
}