Skip to content

Commit

Permalink
feat: display DN information on certificate
Browse files Browse the repository at this point in the history
Issue: #90
  • Loading branch information
pimg committed Aug 29, 2024
1 parent 9f97fe8 commit 94be29b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/ports/models/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func (c *CertificateModel) View() string {

s.WriteString(c.styles.RevokedCertificateText.Render("Serialnumber: ") + c.certificate.SerialNumber.String())
s.WriteString(c.styles.RevokedCertificateText.Render("CommonName: ") + c.certificate.Subject.CommonName)
s.WriteString(c.styles.RevokedCertificateText.Render("DN: ") + c.parseDN(c.certificate.Subject.String()))
s.WriteString(c.parseCountry(c.certificate.Subject.Country))
s.WriteString(c.styles.RevokedCertificateText.Render("Issuer: ") + c.certificate.Issuer.String())
s.WriteString(c.styles.RevokedCertificateText.Render("NotBefore: ") + c.certificate.NotBefore.String())
Expand Down Expand Up @@ -124,6 +125,16 @@ func (c *CertificateModel) View() string {
return lipgloss.JoinVertical(lipgloss.Top, certInfo)
}

func (c *CertificateModel) parseDN(dn string) string {
var s strings.Builder
for _, k := range strings.Split(dn, ",") {
sep := strings.Index(k, "=")
s.WriteString(c.styles.RevokedCertificateText.Render("\t"+k[:sep]+": ") + k[sep+1:])
}

return s.String()
}

func (c *CertificateModel) parseCountry(countries []string) string {
if len(countries) == 0 {
return ""
Expand Down

0 comments on commit 94be29b

Please sign in to comment.