{"record":{"id":"c54821ad1f59d873","repo":"XTLS/Xray-core","slug":"marshal-minecraft-rsa-public-key-w","errorCode":null,"errorMessage":"marshal minecraft rsa public key: %w","messagePattern":"marshal minecraft rsa public key: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"infra/conf/transport_finalmask.go","lineNumber":777,"sourceCode":"}\n\nfunc (c *XMC) Build() (proto.Message, error) {\n\tif len(c.Profiles) == 0 {\n\t\treturn nil, fmt.Errorf(\"minecraft profiles are required\")\n\t}\n\n\tif c.Password == \"\" {\n\t\treturn nil, fmt.Errorf(\"empty password\")\n\t}\n\n\trsaPrivateKey, err := xmc.DeriveRSAKey(c.Password)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"derive minecraft rsa key: %w\", err)\n\t}\n\n\trsaPublicKey, err := x509.MarshalPKIXPublicKey(&rsaPrivateKey.PublicKey)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"marshal minecraft rsa public key: %w\", err)\n\t}\n\n\tprofiles := make([]*xmc.Profile, 0, len(c.Profiles))\n\tfor i := range c.Profiles {\n\t\tprofile, err := c.Profiles[i].Build()\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"build minecraft profile %d: %w\", i, err)\n\t\t}\n\t\tprofiles = append(profiles, profile)\n\t}\n\n\treturn &xmc.Config{\n\t\tPassword:      c.Password,\n\t\tHostname:      c.Hostname,\n\t\tRsaPrivateKey: x509.MarshalPKCS1PrivateKey(rsaPrivateKey),\n\t\tRsaPublicKey:  rsaPublicKey,\n\t\tProfiles:      profiles,\n\t}, nil","sourceCodeStart":759,"sourceCodeEnd":795,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/infra/conf/transport_finalmask.go#L759-L795","documentation":"After deriving the RSA key, XMC.Build serializes the public half with x509.MarshalPKIXPublicKey; failure is wrapped here. MarshalPKIXPublicKey on a standard *rsa.PublicKey essentially cannot fail in current Go, so this is a defensive guard around an internal invariant.","triggerScenarios":"Only reachable if the derived RSA public key is somehow malformed (nil, non-positive modulus) after DeriveRSAKey succeeded — effectively an internal-error path rather than a user-input error.","commonSituations":"Not encountered in normal operation; would indicate a corrupted derivation result or a Go stdlib regression.","solutions":["Treat as an internal failure: retry with a different password to regenerate the key pair","Update xray-core to the latest patch release in case of a fixed derivation bug","Report upstream with the wrapped error and xray version"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat as internal invariant failure — retry with a different password","Stay on patched xray-core releases","Report upstream if reproducible"],"tags":["xmc","minecraft","crypto","x509"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}