{"record":{"id":"4eae90ef0abc6063","repo":"AlistGo/alist","slug":"failed-to-parse-pem-block-containing-the-key","errorCode":null,"errorMessage":"failed to parse PEM block containing the key","messagePattern":"failed to parse PEM block containing the key","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/sftp/hostkey.go","lineNumber":98,"sourceCode":"\t\treturn nil, false\n\t}\n\treturn ret, true\n}\n\nfunc rsaEncodePrivateKey(privateKey *rsa.PrivateKey) []byte {\n\tprivateKeyBytes := x509.MarshalPKCS1PrivateKey(privateKey)\n\tprivateBlock := &pem.Block{\n\t\tType:    \"RSA PRIVATE KEY\",\n\t\tHeaders: nil,\n\t\tBytes:   privateKeyBytes,\n\t}\n\treturn pem.EncodeToMemory(privateBlock)\n}\n\nfunc rsaDecodePrivateKey(bytes []byte) (*rsa.PrivateKey, error) {\n\tblock, _ := pem.Decode(bytes)\n\tif block == nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse PEM block containing the key\")\n\t}\n\tprivateKey, err := x509.ParsePKCS1PrivateKey(block.Bytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn privateKey, nil\n}\n","sourceCodeStart":80,"sourceCodeEnd":106,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/server/sftp/hostkey.go#L80-L106","documentation":"Error \"failed to parse PEM block containing the key\" thrown in AlistGo/alist.","triggerScenarios":"Thrown at server/sftp/hostkey.go:98 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the storage configuration and the provider's service status, fix the indicated cause, and retry the operation."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}