Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle BMPString properly in e_subject_dn_not_printable_characters #819

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions v3/lints/rfc/lint_subject_dn_not_printable_characters.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
package rfc

import (
"unicode/utf8"

"github.com/zmap/zcrypto/encoding/asn1"
"github.com/zmap/zcrypto/x509"
"github.com/zmap/zlint/v3/lint"
Expand Down Expand Up @@ -59,15 +57,20 @@ func (l *subjectDNNotPrintableCharacters) Execute(c *x509.Certificate) *lint.Lin
for _, attrTypeAndValueSet := range rdnSequence {
for _, attrTypeAndValue := range attrTypeAndValueSet {
bytes := attrTypeAndValue.Value.Bytes
for len(bytes) > 0 {
r, size := utf8.DecodeRune(bytes)
var runes []rune
if attrTypeAndValue.Value.Tag == tagBMPString {
runestr, _ := util.ParseBMPString(bytes)
runes = []rune(runestr)
} else {
runes = []rune(string(bytes))
}
for _, r := range runes {
if r < 0x20 {
return &lint.LintResult{Status: lint.Error}
}
if r >= 0x7F && r <= 0x9F {
return &lint.LintResult{Status: lint.Error}
}
bytes = bytes[size:]
}
}
}
Expand Down
Loading