-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CertificateException due to PEM being decoded in CertUtils #3083
Comments
@sonicloong : Thanks a lot for reporting this issue. I tested with your PEM string and I can reproduce this issue. I think if byte[] bytes;
try {
bytes = Base64.getDecoder().decode(data);
} catch (IllegalArgumentException illegalArgumentException) {
bytes = data.getBytes();
}
return new ByteArrayInputStream(bytes); I will create a PR to replace |
rohanKanojia
added a commit
to rohanKanojia/kubernetes-client
that referenced
this issue
Jul 5, 2021
…CertUtils Use java.util.Base64 instead of okio.ByteString to decode base64 encoded string since former one throws IllegalArgumentException in case input string in invalid base64 encoded string. okio.ByteString returns non-null value even for invalid base64 decoded strings Signed-off-by: Rohan Kumar <[email protected]>
11 tasks
rohanKanojia
added a commit
to rohanKanojia/kubernetes-client
that referenced
this issue
Jul 5, 2021
…CertUtils Use java.util.Base64 instead of okio.ByteString to decode base64 encoded string since former one throws IllegalArgumentException in case input string in invalid base64 encoded string. okio.ByteString returns non-null value even for invalid base64 decoded strings Signed-off-by: Rohan Kumar <[email protected]>
manusa
pushed a commit
that referenced
this issue
Jul 5, 2021
Use java.util.Base64 instead of okio.ByteString to decode base64 encoded string since former one throws IllegalArgumentException in case input string in invalid base64 encoded string. okio.ByteString returns non-null value even for invalid base64 decoded strings Signed-off-by: Rohan Kumar <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It looks like
CertUtils#getInputStreamFromDataOrFile
determines whether the certificate data is base64 encoded or not by checking if the data can be base64 decoded. However since okio considers the minus sign to be a valid character(reference), even PEM data can be base64 decoded.
Observed the issue at OpenIDConnectionUtils#getOIDCProviderTokenEndpointAndRefreshToken, which calls getSSLContext, where the certificate data is decoded to PEM already; the PEM is then passed to SSLUtils#trustManagers, then CertUtils#createTrustStore, and eventually CertUtils#getInputStreamFromDataOrFile.
ByteString.decodeBase64(data)
returns non-null value, therefore the PEM is decoded again.Also observed the same issue when passing PEM data to
ConfigBuilder#withCaCertData
Reproduce
Use one of the DigiCert root CAs as an example
Pass it to
ByteString#decodeBase64
, get non-null result.The text was updated successfully, but these errors were encountered: