{"record":{"id":"39471f4dc5bfb0d3","repo":"caddyserver/caddy","slug":"creating-new-stek-v","errorCode":null,"errorMessage":"creating new STEK: %v","messagePattern":"creating new STEK: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/caddytls/distributedstek/distributedstek.go","lineNumber":165,"sourceCode":"// currently exists, a new STEK is created and persisted. If the\n// current STEK is outdated (NextRotation time is in the past),\n// then it is rotated and persisted. The resulting STEK is returned.\nfunc (s *Provider) getSTEK() (distributedSTEK, error) {\n\terr := s.storage.Lock(s.ctx, stekLockName)\n\tif err != nil {\n\t\treturn distributedSTEK{}, fmt.Errorf(\"failed to acquire storage lock: %v\", err)\n\t}\n\n\t//nolint:errcheck\n\tdefer s.storage.Unlock(s.ctx, stekLockName)\n\n\t// load the current STEKs from storage\n\tdstek, err := s.loadSTEK()\n\tif errors.Is(err, fs.ErrNotExist) {\n\t\t// if there is none, then make some right away\n\t\tdstek, err = s.rotateKeys(dstek)\n\t\tif err != nil {\n\t\t\treturn dstek, fmt.Errorf(\"creating new STEK: %v\", err)\n\t\t}\n\t} else if err != nil {\n\t\t// some other error, that's a problem\n\t\treturn dstek, fmt.Errorf(\"loading STEK: %v\", err)\n\t} else if time.Now().After(dstek.NextRotation) {\n\t\t// if current STEKs are outdated, rotate them\n\t\tdstek, err = s.rotateKeys(dstek)\n\t\tif err != nil {\n\t\t\treturn dstek, fmt.Errorf(\"rotating keys: %v\", err)\n\t\t}\n\t}\n\n\treturn dstek, nil\n}\n\n// rotateKeys rotates the keys of oldSTEK and returns the new distributedSTEK\n// with updated keys and timestamps. It stores the returned STEK in storage,\n// so this function must only be called in a storage-provided lock.","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/modules/caddytls/distributedstek/distributedstek.go#L147-L183","documentation":"Error \"creating new STEK: %v\" thrown in caddyserver/caddy.","triggerScenarios":"Thrown at modules/caddytls/distributedstek/distributedstek.go:165 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the wrapped error; this usually indicates a crypto/RNG failure on the host."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}