调试注册错误
Tink 有时会生成错误消息,例如
No wrapper registered for type
No manager for type T has been registered
Unable to get primitive interface P for key of type T
本页面有助于调试此类问题。
情况 1:该错误会带有“No wrapper found”或类似字样。
您要调用 GetPrimitive()
来获取尚未注册的基本类型,通常可以通过在二进制文件中的较早位置调用 TinkConfig.register()
来解决此问题。只需注册一次即可,并且可在启动时完成。
某些基元需要更专业的注册。
KeysetDeriver
要求订阅KeyDerivationConfig.register()
JwtMac
要求订阅JwtMacConfig.register()
JwtPublicKeySign
和 JwtPublicKeyVerify
需要 JwtSignatureConfig.register()
情况 2:该错误列出了密钥类型和基元。
例如,对于 P 和 T 的某个特定值,错误可能会显示 Unable to get primitive interface P for key
of type T
。
在这种情况下,Tink 无法针对您拥有的密钥集创建您要求它的特定基元。这通常是因为密钥集类型错误。例如,您可能要求使用 Mac,但密钥集是面向 Aead 的。
一种常见的情况是尝试从包含私钥的密钥集中获取公钥基元。如需了解这是否就是问题所在,请考虑改为对 GetPublicKeysetHandle()
的结果调用 GetPrimitive()
。
如果这没有帮助,请在此处的跨语言测试中查看密钥类型的最新列表。您应检查基元 P 是否与密钥类型 T 一起列出。
如果基元与相应的密钥类型一起列出,可能是因为您语言的 Tink 实现不支持密钥类型 T。请查看密钥类型列表,了解 Tink 是否支持您的密钥类型以您的语言显示。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-03-04。
[null,null,["最后更新时间 (UTC):2024-03-04。"],[[["Tink error messages like \"No wrapper registered\" often indicate missing primitive registration, fixable with `TinkConfig.register()`."],["Errors mentioning key type and primitive usually mean an incompatible keyset is used, like requesting a Mac with an Aead keyset."],["Public key primitives require keysets obtained via `GetPublicKeysetHandle()` to avoid key type mismatches."],["Verify key type and primitive compatibility by checking the cross-language test resources and supported key types documentation for your language."]]],["Tink error messages like \"No wrapper registered\" or \"Unable to get primitive\" indicate issues with key and primitive type registration or compatibility. For \"No wrapper\" errors, register the type using `TinkConfig.register()` or specialized methods like `KeyDerivationConfig.register()`. For primitive-key type mismatches, verify that the keyset's type matches the requested primitive, and use `GetPublicKeysetHandle()` for public keys. Check supported key type lists if registration or type-checking does not fix the issue.\n"]]