Key Distribution
Light-Java and Light-OAuth2 support distributed security verification and this requires the JWT public key certificate to be distributed to all services. By default, all services built on top of Light-Java will include a set of certificates. But how do you distribute new certificates to thousands of running services if certificates are renewed? There is no way we can copy certificates to all the running containers as they are dynamic and new containers can be started anytime by container orchestration tool.
The traditional push approach does not work, and a new way of pull certificates from OAuth2 key service is implemented in Light-Java and Light-OAuth2.
This feature is tightly integrated with Light-Java and it should work seamlessly.
The first step to get certificate is to encode client_id:client_secret pair for basic authentication.
Here is the client_id:client_secret
f7d42348-c647-4efb-a52d-4c5787421e72:f6h1FTI8Q3-7UScPZDzfXA
Go to https://www.base64encode.org/ to encode it to
ZjdkNDIzNDgtYzY0Ny00ZWZiLWE1MmQtNGM1Nzg3NDIxZTcyOmY2aDFGVEk4UTMtN1VTY1BaRHpmWEE=
To get certificate by a key id.
curl -k -H "Authorization: Basic ZjdkNDIzNDgtYzY0Ny00ZWZiLWE1MmQtNGM1Nzg3NDIxZTcyOmY2aDFGVEk4UTMtN1VTY1BaRHpmWEE=" https://localhost:6886/oauth2/key/101
And here is the result.
-----BEGIN CERTIFICATE-----
MIIDkzCCAnugAwIBAgIEUBGbJDANBgkqhkiG9w0BAQsFADB6MQswCQYDVQQGEwJDQTEQMA4GA1UE
CBMHT250YXJpbzEQMA4GA1UEBxMHVG9yb250bzEmMCQGA1UEChMdTmV0d29yayBOZXcgVGVjaG5v
bG9naWVzIEluYy4xDDAKBgNVBAsTA0FQSTERMA8GA1UEAxMIU3RldmUgSHUwHhcNMTYwOTIyMjI1
OTIxWhcNMjYwODAxMjI1OTIxWjB6MQswCQYDVQQGEwJDQTEQMA4GA1UECBMHT250YXJpbzEQMA4G
A1UEBxMHVG9yb250bzEmMCQGA1UEChMdTmV0d29yayBOZXcgVGVjaG5vbG9naWVzIEluYy4xDDAK
BgNVBAsTA0FQSTERMA8GA1UEAxMIU3RldmUgSHUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
AoIBAQCqYfarFwug2DwpG/m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