创建 jwt 签名者时签名算法错误
Signing algorithm error while creating a jwt signer
我正在使用 Vapor jwt 包,但在创建私有 jwt 签名者时遇到此类错误:
Swift/ErrorType.swift:200: Fatal error: Error raised at top level: JWTKit error: signing algorithm error: bioConversionFailure
错误发生在这段代码的第 2 行:
let privateKey = try String(contentsOfFile: app.directory.workingDirectory + "jwt.key")
let privateSigner = try JWTSigner.rs256(key: .private(pem: privateKey.bytes))
let publicKey = try String(contentsOfFile: app.directory.workingDirectory + "jwt.key.pub")
let publicSigner = try JWTSigner.rs256(key: .public(pem: publicKey.bytes))
这是 jwt.key
的样子(我会隐藏一些符号):
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,49892B69BD216[...]84A1DD2A9248FD
fxGXzOPc+7LDp6Jm/PkMp1E/sq7ncOeT5JdmSxbE5yIYIRngqcxfBC8IkIgkd/hv
ACpH55VQE2lgZuXDHcOJU1ivhcW3uo3mn5hhCswDdJ6zFerHonUzNpeQAvs2woqT
[....]
Z/hTsA1MTRGubzMb3SHFoVLiVj2FJ5SP7qrSDtB7xgB0/rKUykpbnR4OQiHH7z+8
sfJZKulMT7DIYIEe/glZCYBOZC2VaaEFr921Smx5Le12hfP1HYFLrX4oTCMLxGP9
-----END RSA PRIVATE KEY-----
无需密码重新生成 RSA 私钥 - 对我有帮助
我正在使用 Vapor jwt 包,但在创建私有 jwt 签名者时遇到此类错误:
Swift/ErrorType.swift:200: Fatal error: Error raised at top level: JWTKit error: signing algorithm error: bioConversionFailure
错误发生在这段代码的第 2 行:
let privateKey = try String(contentsOfFile: app.directory.workingDirectory + "jwt.key")
let privateSigner = try JWTSigner.rs256(key: .private(pem: privateKey.bytes))
let publicKey = try String(contentsOfFile: app.directory.workingDirectory + "jwt.key.pub")
let publicSigner = try JWTSigner.rs256(key: .public(pem: publicKey.bytes))
这是 jwt.key
的样子(我会隐藏一些符号):
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,49892B69BD216[...]84A1DD2A9248FD
fxGXzOPc+7LDp6Jm/PkMp1E/sq7ncOeT5JdmSxbE5yIYIRngqcxfBC8IkIgkd/hv
ACpH55VQE2lgZuXDHcOJU1ivhcW3uo3mn5hhCswDdJ6zFerHonUzNpeQAvs2woqT
[....]
Z/hTsA1MTRGubzMb3SHFoVLiVj2FJ5SP7qrSDtB7xgB0/rKUykpbnR4OQiHH7z+8
sfJZKulMT7DIYIEe/glZCYBOZC2VaaEFr921Smx5Le12hfP1HYFLrX4oTCMLxGP9
-----END RSA PRIVATE KEY-----
无需密码重新生成 RSA 私钥 - 对我有帮助