XTLS/Xray-core · error

: invalid value (BaseKey must be 32 bytes):

Error message

: invalid value (BaseKey must be 32 bytes): 

What it means

Error ": invalid value (BaseKey must be 32 bytes): " thrown in XTLS/Xray-core.

Source

Thrown at common/xudp/xudp.go:43

	protocol.AddressFamilyByte(byte(protocol.AddressTypeIPv6), net.AddressFamilyIPv6),
	protocol.PortThenAddress(),
)

var (
	Show    atomic.Bool
	baseKey atomic.Value
)

func reloadEnvSettings() error {
	Show.Store(strings.ToLower(platform.NewEnvFlag(platform.XUDPLog).GetValue(func() string { return "" })) == "true")
	raw := platform.NewEnvFlag(platform.XUDPBaseKey).GetValue(func() string { return "" })
	if raw == "" {
		ensureBaseKey()
		return nil
	}
	key, _ := base64.RawURLEncoding.DecodeString(raw)
	if len(key) != 32 {
		return errors.New(platform.XUDPBaseKey + ": invalid value (BaseKey must be 32 bytes): " + raw + " len " + strconv.Itoa(len(key)))
	}
	baseKey.Store(append([]byte(nil), key...))
	return nil
}

func ensureBaseKey() []byte {
	if key := baseKey.Load(); key != nil {
		return key.([]byte)
	}
	key := make([]byte, 32)
	if _, err := rand.Read(key); err != nil {
		panic(err)
	}
	baseKey.Store(key)
	return key
}

func init() {

View on GitHub (pinned to 7d214f8b09)

When it happens

Trigger: Thrown at common/xudp/xudp.go:43 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15). Data as JSON: /api/errors/129ad555f8c9ae10. Report an issue: GitHub.