gpt4 book ai didi

python - 如何在 jwks_uri 端点中为 OpenID Connect Discovery 返回 RSA key

转载 作者:行者123 更新时间:2023-12-05 03:13:21 27 4
gpt4 key购买 nike

在 OpenID Connect 提供商的发现部分工作时,我对如何正确返回我的公共(public) key 感到有点困惑。我的问题特别在于 modulus (n)exponent (e) 值。

两者的初始值为:

n = 124692971944797177402996703053303877641609106436730124136075828918287037758927191447826707233876916396730936365584704201525802806009892366608834910101419219957891196104538322266555160652329444921468362525907130134965311064068870381940624996449410632960760491317833379253431879193412822078872504618021680609253

e = 65537

所以,我读懂了here , 只需要对两者进行 base64url 编码。

(Python 示例)

n = urlsafe_b64encode(str(n))
e = urlsafe_b64encode(str(e))

n = "MTI0NjkyOTcxOTQ0Nzk3MTc3NDAyOTk2NzAzMDUzMzAzODc3NjQxNjA5MTA2NDM2NzMwMTI0MTM2MDc1ODI4OTE4Mjg3MDM3NzU4OTI3MTkxNDQ3ODI2NzA3MjMzODc2OTE2Mzk2NzMwOTM2MzY1NTg0NzA0MjAxNTI1ODAyODA2MDA5ODkyMzY2NjA4ODM0OTEwMTAxNDE5MjE5OTU3ODkxMTk2MTA0NTM4MzIyMjY2NTU1MTYwNjUyMzI5NDQ0OTIxNDY4MzYyNTI1OTA3MTMwMTM0OTY1MzExMDY0MDY4ODcwMzgxOTQwNjI0OTk2NDQ5NDEwNjMyOTYwNzYwNDkxMzE3ODMzMzc5MjUzNDMxODc5MTkzNDEyODIyMDc4ODcyNTA0NjE4MDIxNjgwNjA5MjUz"
e = "NjU1Mzc="

我哪里错了?因为,例如,google keys有不同的编码。

(Google 键值)

n = "rl1iVsRbhod-gDJj2SDs94lk5iY0QYXV5HIPtjcx4KmIlmq-cdmfLteTeIHFsO5c6hKUt8R3uZzaQNgF3fKt700fT4m6tU23qK4EoLlx9Z_uSajtpMajdmX_FOdyHyQgcn0tj3YqPeYCOTBhRVNoLIenf9vy0hfFy71lcPhylnE",
e = "AQAB"

我错过了什么吗?感谢您的宝贵时间。

PD:The project I'm working on .

最佳答案

您正在对值的十进制表示进行 base64url 编码,但您应该对八位字节值进行 base64url 编码,即此处定义的大端字节序列:https://www.rfc-editor.org/rfc/rfc7518#section-6.3.1.1在这里 https://www.rfc-editor.org/rfc/rfc7518#section-2

Base64urlUInt

The representation of a positive or zero integer value as thebase64url encoding of the value's unsigned big-endianrepresentation as an octet sequence. The octet sequence MUSTutilize the minimum number of octets needed to represent thevalue. Zero is represented as BASE64URL(single zero-valuedoctet), which is "AA".

关于python - 如何在 jwks_uri 端点中为 OpenID Connect Discovery 返回 RSA key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30537328/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com