mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-26 20:26:19 +08:00
MAGIC - align code order
This commit is contained in:
parent
913a90b94e
commit
6ab6b29261
@ -338,6 +338,41 @@ func (c *Certificate) checkNameConstraints(count *int,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// domainToReverseLabels converts a textual domain name like foo.example.com to
|
||||||
|
// the list of labels in reverse order, e.g. ["com", "example", "foo"].
|
||||||
|
func domainToReverseLabels(domain string) (reverseLabels []string, ok bool) {
|
||||||
|
for len(domain) > 0 {
|
||||||
|
if i := strings.LastIndexByte(domain, '.'); i == -1 {
|
||||||
|
reverseLabels = append(reverseLabels, domain)
|
||||||
|
domain = ""
|
||||||
|
} else {
|
||||||
|
reverseLabels = append(reverseLabels, domain[i+1:])
|
||||||
|
domain = domain[:i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(reverseLabels) > 0 && len(reverseLabels[0]) == 0 {
|
||||||
|
// An empty label at the end indicates an absolute value.
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, label := range reverseLabels {
|
||||||
|
if len(label) == 0 {
|
||||||
|
// Empty labels are otherwise invalid.
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, c := range label {
|
||||||
|
if c < 33 || c > 126 {
|
||||||
|
// Invalid character.
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return reverseLabels, true
|
||||||
|
}
|
||||||
|
|
||||||
// isValid performs validity checks on c given that it is a candidate to append
|
// isValid performs validity checks on c given that it is a candidate to append
|
||||||
// to the chain in currentChain.
|
// to the chain in currentChain.
|
||||||
func (c *Certificate) isValid(certType int, currentChain []*Certificate, opts *VerifyOptions) error {
|
func (c *Certificate) isValid(certType int, currentChain []*Certificate, opts *VerifyOptions) error {
|
||||||
|
2682
smx509/x509.go
2682
smx509/x509.go
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user