Skip to content

Commit

Permalink
Include public key details for x.509 certificates
Browse files Browse the repository at this point in the history
  • Loading branch information
edutko committed Jun 20, 2023
1 parent 2dfcef0 commit dc795eb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions internal/file/der.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,24 @@ func parseCertificate(der []byte) (Info, error) {
return UnknownASN1Data, err
}

return Info{
info := Info{
Description: "x.509 certificate",
Attributes: []Attribute{
{"Serial", c.SerialNumber.String()},
{"Subject", c.Subject.String()},
{"Issuer", c.Issuer.String()},
{"Expiration", c.NotAfter.Format("2006-01-02")},
{"Public key algorithm", c.PublicKeyAlgorithm.String()},
{"Signature algorithm", c.SignatureAlgorithm.String()},
},
}, nil
Children: []Info{
{
Description: "Public key",
Attributes: cryptoPublicKeyAttributes(c.PublicKey),
},
},
}

return info, nil
}

func parsePKCS1PublicKey(der []byte) (Info, error) {
Expand Down
1 change: 1 addition & 0 deletions internal/file/parsers.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func PEMFile(info Info, data []byte) (Info, error) {
if len(blockInfos) == 1 {
info.Description = blockInfos[0].Description
info.Attributes = blockInfos[0].Attributes
info.Children = blockInfos[0].Children
return info, nil

} else if len(blockInfos) > 1 {
Expand Down

0 comments on commit dc795eb

Please sign in to comment.