{"record":{"id":"e2d6c2643bd5e1fa","repo":"valyala/fasthttp","slug":"cert-or-key-has-not-provided","errorCode":null,"errorMessage":"cert or key has not provided","messagePattern":"cert or key has not provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server.go","lineNumber":20,"sourceCode":"\nimport (\n\t\"bufio\"\n\t\"context\"\n\t\"crypto/tls\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"log\"\n\t\"mime/multipart\"\n\t\"net\"\n\t\"os\"\n\t\"strings\"\n\t\"sync\"\n\t\"sync/atomic\"\n\t\"time\"\n)\n\nvar errNoCertOrKeyProvided = errors.New(\"cert or key has not provided\")\n\n// ErrAlreadyServing is deprecated.\n//\n// Deprecated: ErrAlreadyServing is never returned from Serve. See issue #633.\nvar ErrAlreadyServing = errors.New(\"fasthttp: server is already serving connections\")\n\n// ServeConn serves HTTP requests from the given connection\n// using the given handler.\n//\n// ServeConn returns nil if all requests from the c are successfully served.\n// It returns non-nil error otherwise.\n//\n// Connection c must immediately propagate all the data passed to Write()\n// to the client. Otherwise requests' processing may hang.\n//\n// ServeConn closes c before returning.\nfunc ServeConn(c net.Conn, handler RequestHandler) error {\n\tv := serverPool.Get()","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/valyala/fasthttp/blob/c96f600972c6f4a7a30d664257b340ebe9d60124/server.go#L2-L38","documentation":"errNoCertOrKeyProvided is an unexported fasthttp server error returned when TLS is expected but neither a certificate nor a key has been supplied to the server. Fasthttp requires at least one cert/key pair (via Certificate or cert/key data) before it can serve TLS connections.","triggerScenarios":"Starting a Server on a TLS listener or with TLS configuration where both CertFile/KeyFile (or the in-memory certificate fields) are empty.","commonSituations":"Config files with TLS section present but empty paths; environment variables for cert paths not set; forgot to call AppendCert or set Certificate after enabling HTTPS.","solutions":["Set Server.CertFile and Server.KeyFile (or use fasthttp.AppendCert / TLSConfig with loaded certificates).","Verify the cert/key config values are actually loaded (env vars, config file) before Serve.","Ensure ListenAndServeTLS is used with valid cert/key arguments."],"exampleFix":"// before\nsrv := &fasthttp.Server{Handler: h}\nsrv.ListenAndServeTLS(\":443\", \"\", \"\") // no cert/key\n// after\nsrv := &fasthttp.Server{Handler: h}\nsrv.ListenAndServeTLS(\":443\", \"/etc/ssl/cert.pem\", \"/etc/ssl/key.pem\")","handlingStrategy":"validation","validationCode":"if cfg.TLSEnabled && (cfg.CertFile == \"\" || cfg.KeyFile == \"\") {\n    return errors.New(\"tls enabled but cert or key path is empty\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate cert/key config at app startup, before ListenAndServeTLS.","Fail fast if TLS is enabled but material is missing.","Prefer loading certs via TLSConfig upfront so missing files error early."],"tags":["tls","certificate","server"],"backgroundTag":"missing-tls-certificate","analyzedSha":"c96f600972c6f4a7a30d664257b340ebe9d60124","analyzedAt":"2026-08-31T22:48:28.265Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}