https://www.googleapis.com/oauth2/v3/certs中v1、v2、v3的区别
Difference between v1, v2 and v3 in https://www.googleapis.com/oauth2/v3/certs
我正在尝试通过 Google Sign-in 对 Android 上的用户进行身份验证以获取帐户名,通过 GoogleAuthUtil.getToken(getApplicationContext(), app, scopes) 获取令牌,然后将令牌发送到我的 NodeJS 后端服务器以验证
我 found this 关于如何对其进行解码、缓存密钥 ID (KID) 以便它不会每次都进行往返等的伟大 Whosebug 问题(尚未实现这部分,但排序玩过它)我唯一的问题是:以下googleapis证书之间有什么区别:
- www.googleapis.com/oauth2/v1/certs
- www.googleapis.com/oauth2/v2/certs
- www.googleapis.com/oauth2/v3/certs
每个版本的KID都是一样的,但是内容明显不同。为什么? v2 和 v3 看起来几乎相同,只是 v2 在 属性 'n'
的值末尾附加了一个“==”
最重要的是,我使用哪个版本?
我认为这些证书称为 JSON Web 密钥 (JWK)。我还读过 'x5c' 那是什么?
PS:我从我的 android 应用程序获取我的 nodejs 的令牌是:
{
"iss": "accounts.google.com",
"sub": "SOME_LONG_NUMBER_THAT_I_DONT_KNOW_IF_SHOULD_SHOW",
"azp": "SERVER_CLIENT_ID",
"email": "ANDROID_USER_EMAIL",
"email_verified": "true",
"aud": "ANDROID_CLIENT_ID",
"iat": "SOME_NUMBER",
"exp": "SOME_NUMBER",
"alg": "RS256",
"kid": "e53139984bd36d2c230552441608cc0b5179487a"
}
Version 1 似乎是密钥 ID 到证书字符串的基本 JSON 映射。我没有任何内部信息,但我推测这是一种简单的“本土”格式,Google 的某个人制作了一种简单的方法来分发他们的 public 密钥。
正如您所注意到的,versions 2 and 3 are distributed in the JSON Web Key (JWK) format. This format is defined in a formal specification, RFC 7517,其中详细说明了如何构建表示加密密钥的 JSON 响应。
至于 v2 和 v3 之间的区别,看起来 v2 包含了 trailing equal signs as padding,而在 v3 中他们只是将那些去掉了。
I've also read the term 'x5c' What is that?
在the specification, 'x5c' is defined as an optional parameter for specifying a list of cryptographic certificates that together form a "chain of trust" that would allow a client application to validate the key by verifying each certificate in turn and following the chain back to a known, trusted root certificate.
Most importantly, which version do I use?
如果可能,我建议使用最新版本。但只要密钥本身是相同的,它可能并不重要。
我正在尝试通过 Google Sign-in 对 Android 上的用户进行身份验证以获取帐户名,通过 GoogleAuthUtil.getToken(getApplicationContext(), app, scopes) 获取令牌,然后将令牌发送到我的 NodeJS 后端服务器以验证
我 found this 关于如何对其进行解码、缓存密钥 ID (KID) 以便它不会每次都进行往返等的伟大 Whosebug 问题(尚未实现这部分,但排序玩过它)我唯一的问题是:以下googleapis证书之间有什么区别:
- www.googleapis.com/oauth2/v1/certs
- www.googleapis.com/oauth2/v2/certs
- www.googleapis.com/oauth2/v3/certs
每个版本的KID都是一样的,但是内容明显不同。为什么? v2 和 v3 看起来几乎相同,只是 v2 在 属性 'n'
的值末尾附加了一个“==”最重要的是,我使用哪个版本?
我认为这些证书称为 JSON Web 密钥 (JWK)。我还读过 'x5c' 那是什么?
PS:我从我的 android 应用程序获取我的 nodejs 的令牌是:
{
"iss": "accounts.google.com",
"sub": "SOME_LONG_NUMBER_THAT_I_DONT_KNOW_IF_SHOULD_SHOW",
"azp": "SERVER_CLIENT_ID",
"email": "ANDROID_USER_EMAIL",
"email_verified": "true",
"aud": "ANDROID_CLIENT_ID",
"iat": "SOME_NUMBER",
"exp": "SOME_NUMBER",
"alg": "RS256",
"kid": "e53139984bd36d2c230552441608cc0b5179487a"
}
Version 1 似乎是密钥 ID 到证书字符串的基本 JSON 映射。我没有任何内部信息,但我推测这是一种简单的“本土”格式,Google 的某个人制作了一种简单的方法来分发他们的 public 密钥。
正如您所注意到的,versions 2 and 3 are distributed in the JSON Web Key (JWK) format. This format is defined in a formal specification, RFC 7517,其中详细说明了如何构建表示加密密钥的 JSON 响应。
至于 v2 和 v3 之间的区别,看起来 v2 包含了 trailing equal signs as padding,而在 v3 中他们只是将那些去掉了。
I've also read the term 'x5c' What is that?
在the specification, 'x5c' is defined as an optional parameter for specifying a list of cryptographic certificates that together form a "chain of trust" that would allow a client application to validate the key by verifying each certificate in turn and following the chain back to a known, trusted root certificate.
Most importantly, which version do I use?
如果可能,我建议使用最新版本。但只要密钥本身是相同的,它可能并不重要。