{"record":{"id":"3232c90c89354a6d","repo":"go-sql-driver/mysql","slug":"invalid-value-unknown-server-pub-key-name-s","errorCode":null,"errorMessage":"invalid value / unknown server pub key name: %s","messagePattern":"invalid value / unknown server pub key name: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dsn.go","lineNumber":225,"sourceCode":"\t\tdefault:\n\t\t\tcfg.TLS = getTLSConfigClone(cfg.TLSConfig)\n\t\t\tif cfg.TLS == nil {\n\t\t\t\treturn errors.New(\"invalid value / unknown config name: \" + cfg.TLSConfig)\n\t\t\t}\n\t\t}\n\t}\n\n\tif cfg.TLS != nil && cfg.TLS.ServerName == \"\" && !cfg.TLS.InsecureSkipVerify {\n\t\thost, _, err := net.SplitHostPort(cfg.Addr)\n\t\tif err == nil {\n\t\t\tcfg.TLS.ServerName = host\n\t\t}\n\t}\n\n\tif cfg.ServerPubKey != \"\" {\n\t\tcfg.pubKey = getServerPubKey(cfg.ServerPubKey)\n\t\tif cfg.pubKey == nil {\n\t\t\treturn errors.New(\"invalid value / unknown server pub key name: \" + cfg.ServerPubKey)\n\t\t}\n\t}\n\n\tif cfg.Logger == nil {\n\t\tcfg.Logger = defaultLogger\n\t}\n\n\treturn nil\n}\n\nfunc writeDSNParam(buf *bytes.Buffer, hasParam *bool, name, value string) {\n\tbuf.Grow(1 + len(name) + 1 + len(value))\n\tif !*hasParam {\n\t\t*hasParam = true\n\t\tbuf.WriteByte('?')\n\t} else {\n\t\tbuf.WriteByte('&')\n\t}","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/go-sql-driver/mysql/blob/03d76c7e07908e255ce62d126d07ede3f2365d86/dsn.go#L207-L243","documentation":"Error \"invalid value / unknown server pub key name: %s\" thrown in go-sql-driver/mysql.","triggerScenarios":"The DSN sets serverPubKey=<name> but no public key with that name was registered via mysql.RegisterServerPubKey.","commonSituations":"Used with caching_sha2_password authentication over an insecure channel where the server's RSA public key is needed. Call mysql.RegisterServerPubKey with the key before connecting, enable TLS, or set allowFallbackToPlaintext where acceptable.","solutions":["Register the server public key with mysql.RegisterServerPubKey(name, key) before using serverPubKey=<name> in the DSN.","Check the name for typos; the registered key name must match the DSN value exactly."],"exampleFix":"key, _ := os.ReadFile(\"server_pub_key.pem\")\nmysql.RegisterServerPubKey(\"mykey\", key)\ndsn := \"user:pass@tcp(dbhost:3306)/mydb?serverPubKey=mykey\"","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"03d76c7e07908e255ce62d126d07ede3f2365d86","analyzedAt":"2026-08-07T10:39:17.340Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}