1
0
mirror of https://github.com/golang/go synced 2024-11-24 23:07:56 -07:00

ignoreCN disables interpreting PrintableString as ASN.1. See issue 21339

This commit is contained in:
hysios 2021-04-01 21:12:14 +08:00 committed by GitHub
parent e6ac2df2b1
commit 15910b851b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,6 +31,9 @@ import (
"unicode/utf8"
)
// ignoreCN disables interpreting PrintableString as ASN.1 See issue 21339
var ignoreCN = !strings.Contains(os.Getenv("GODEBUG"), "x509ignoreCN=0")
// A StructuralError suggests that the ASN.1 data is valid, but the Go type
// which is receiving it doesn't match.
type StructuralError struct {
@ -404,7 +407,7 @@ func isNumeric(b byte) bool {
// array and returns it.
func parsePrintableString(bytes []byte) (ret string, err error) {
for _, b := range bytes {
if !isPrintable(b, allowAsterisk, allowAmpersand) {
if !ignoreCN && !isPrintable(b, allowAsterisk, allowAmpersand) {
err = SyntaxError{"PrintableString contains invalid character"}
return
}