当秘密旋转时,我们如何最大程度地减少AWS-ScretsManager-Caching-Python中的滞后?
我们正在使用AWS Secrets Manager存储公共/私钥,以加密服务之间的解密消息,并希望旋转秘密。
aws-secretsmanager-caching-python 看起来非常适合缓解我们的秘密,但它具有刷新间隔,默认为一个小时。
在1-60分钟的旧秘密被缓存而不会再解密消息的1-60分钟内会发生什么?我们可以检测到秘密不再起作用。一旦我们发现了这一点,我们是否有一种方法可以迫使价值刷新?处理此问题的意图方法是什么?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尽管AWS推荐解决秘密经理的缓存秘密的建议解决方案,并建议它支持秘密轮换,但AWS-ScretsManager-Caching-Python库似乎并没有支持驱动驱动,这是密钥旋转所需的。 建议他们正在测试刷新秘密:
但是,代码设置了一个初始秘密,创建了一个带有小刷新间隔的新配置,甚至没有使用,并测试了10次将秘密设置为最初的秘诀。它根本没有测试令人耳目一新,看起来代码仍然半烘烤。
Despite being the aws recommended solution for caching secrets from secrets manager and the docs suggesting it supports secret rotation, the aws-secretsmanager-caching-python library doesn't appear to support eviction which would be needed for key rotation. This unit test suggests they are testing refreshing the secret:
But, the code sets an initial secret, creates a new config with a small refresh interval which is then not even used, and tests 10 times that the secret was set to what it was initially. It isn't testing refreshing at all and looks like the code is still half baked.
旋转的秘密没有应用停机时间,就需要能够同时拥有两个可用的秘密(根据时间点,当前,下一个或当前或上一个以及以前的秘密)。如果您使用此信息进行加密,则该消息必须包含一个未加密的指针,指向使用的秘密版本。然后,接收器可以发现用于消息的加密密钥。
但是,一种更好的加密替代方法是使用 kms (这是Secrets Manager的使用) 。在此方案中,您将KMS生成的Atatakey称为“加密密钥”的明文和加密版本。您可以使用“明文密钥”加密有效载荷,并在消息中发送加密的密钥和加密有效载荷。然后,接收器打电话给KMS以解密加密的数据密钥,然后使用该密钥解密有效载荷。这样,您不必管理关键版本。您也可以使用KMS使用对称或不对称键。
Rotating secrets without application down time requires being able to have at least two usable secrets in flight at the same time (the current and next or current and previous depending on the point in time). If you are using this for encryption, then the message must contain an unencrypted pointer to the version of the secret to use. Then the receiver can discover which encryption key to use for the message.
A better alternative for encryption, though, would be to use KMS (which is what Secrets Manager uses). In this scheme, you call KMS GenerateDataKey to get both a plaintext and encrypted version of an encryption key. You encrypt the payload using the plaintext key, and send the encrypted key and encrypted payload in the message. The reciever then calls KMS to decrypt the encrypted data key and then uses that to decrypt the payload. This way, you do not have to manage key versions. You can also use either symmetric or asymmetric keys with KMS.