From 0dd93f25fbbbc50105665e647beea70c3b7f2ac5 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 26 Dec 2018 16:55:09 -0500 Subject: crtsh-pem2html: Properly display rows with only precerts --- bin-src/crtsh-pem2html.go | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/bin-src/crtsh-pem2html.go b/bin-src/crtsh-pem2html.go index 432020e..f916bf6 100644 --- a/bin-src/crtsh-pem2html.go +++ b/bin-src/crtsh-pem2html.go @@ -56,12 +56,12 @@ var tmpl = template.Must(template.New("pem2html"). SCTs {{range $cert := .certs}} - - {{$cert.Updated | date}} - {{$cert.Main.X509.NotBefore | date}} - {{$cert.Main.X509.NotAfter | date}} - {{$cert.Main.X509.Subject.CommonName}} - {{$cert.Main.X509.Issuer.Organization}} + + {{$cert.Updated | date}} + {{(index $cert 0).X509.NotBefore | date}} + {{(index $cert 0).X509.NotAfter | date}} + {{(index $cert 0).X509.Subject.CommonName}} + {{(index $cert 0).X509.Issuer.Organization}} {{range $i, $sct := $cert.Precerts}} [{{$i}}] {{end}} @@ -142,14 +142,21 @@ func NewCertSet(certs []Cert) []CertSet { return ret } +func (certs CertSet) IsValid() bool { + return !util.IsPrecertificate(certs[0].X509) +} + func (certs CertSet) Main() Cert { - //if util.IsPrecertificate(certs[0].X509) { - // return Cert{X509: new(x509.Certificate)} - //} + if util.IsPrecertificate(certs[0].X509) { + return Cert{X509: new(x509.Certificate)} + } return certs[0] } func (certs CertSet) Precerts() []Cert { + if util.IsPrecertificate(certs[0].X509) { + return certs + } return certs[1:] } -- cgit v1.1-4-g5e80