从以下 Stripe 的 Webhooks 文档中可以看出,Webhook 签名密钥将在最长 24 小时的持续时间内轮换 - https://stripe.com/docs/webhooks#roll-endpoint-secrets
现在,如果我们将此密钥存储在服务器端来验证 Webhook 签名,那么每 24 小时在服务器上手动更新此密钥就会变得很麻烦。
- 有什么方法可以自动禁用此签名密钥的轮换吗?
- 如果没有,是否有任何 API 可以让我们在服务器中获取此签名密钥?
- 如果不是,那么如果我们不想在服务器上手动更新签名密钥每 24 小时轮换一次的情况,我们该如何处理呢?
我认为您误读了文档。Webhook 密钥不会过期,除非您想自行推出(通过仪表板)。如果是这样,您可以选择立即推出它,以便您也可以立即更新服务器中的新值或将其过期延迟最多 24 小时[1]。在添加延迟的情况下,您需要考虑使用太秘密的密钥(新的和旧的)[2] 进行验证,以便您有足够的时间在服务器中推出新值。
[1] https://stripe.com/docs/webhooks#roll-endpoint-secrets:~:text=You%20can%20choose%20to%20immediately%20expire%20the%20current%20secret%20or%20delay%20its%20expiration %20for%20up%20to%2024%20hours%20to%20allow%20yourself%20time%20to%20update%20the%20verification%20code%20on%20your%20server
[2] https://stripe.com/docs/webhooks#roll-endpoint-secrets:~:text=During%20this%20time%2C%20multiple%20secrets%20are%20active%20for%20the%20endpoint.%20Stripe% 20生成%20one%20signature%20per%20secret%20until%20expiration。