Skip to content

Commit

Permalink
README to suggest checking x509.ParseCertificate error (#460)
Browse files Browse the repository at this point in the history
* example to check output

* Spacing fix

* Update README.md

* filter error
  • Loading branch information
zakird committed Aug 4, 2020
1 parent ada0991 commit 3f689d2
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,12 @@ import (
)

var certDER []byte = ...
parsed, _ := x509.ParseCertificate(certDER)
parsed, err := x509.ParseCertificate(certDER)
if err != nil {
// If x509.ParseCertificate fails, the certificate is too broken to lint.
// This should be treated as ZLint rejecting the certificate
log.Fatal("unable to parse certificate:", err)
}
zlintResultSet := zlint.LintCertificate(parsed)
```

Expand All @@ -126,11 +131,19 @@ import (
)

var certDER []byte = ...
parsed, _ := x509.ParseCertificate(certDER)

registry, _ := lint.GlobalRegistry().Filter(lint.FilterOptions{
parsed, err := x509.ParseCertificate(certDER)
if err != nil {
// If x509.ParseCertificate fails, the certificate is too broken to lint.
// This should be treated as ZLint rejecting the certificate
log.Fatal("unable to parse certificate:", err)
}

registry, err := lint.GlobalRegistry().Filter(lint.FilterOptions{
ExcludeSources: []lint.LintSource{lint.EtsiEsi},
})
if err != nil {
log.Fatal("lint registry filter failed to apply:", err)
}
zlintResultSet := zlint.LintCertificateEx(parsed, registry)
```

Expand Down

0 comments on commit 3f689d2

Please sign in to comment.