Skip to content

Improve empty cert chain handling in TrustManagers#162

Open
aww-aww wants to merge 2 commits into
appmattus:mainfrom
aww-aww:main
Open

Improve empty cert chain handling in TrustManagers#162
aww-aww wants to merge 2 commits into
appmattus:mainfrom
aww-aww:main

Conversation

@aww-aww
Copy link
Copy Markdown

@aww-aww aww-aww commented Mar 24, 2026

Update the checkClientTrusted and checkServerTrusted methods in CertificateTransparencyTrustManagerBasic and CertificateTransparencyTrustManagerExtended to validate that the provided certificate chain and authType are not null or empty. Preventing a NoSuchElementException from being thrown when chain.first() is called on an empty chain, and ensuring we instead throw an IllegalArgumentException as expected by X509TrustManager.

google-labs-jules Bot and others added 2 commits March 24, 2026 17:06
Updates the `checkClientTrusted` and `checkServerTrusted` methods in
`CertificateTransparencyTrustManagerBasic` and
`CertificateTransparencyTrustManagerExtended` to validate that the provided
certificate chain and authType are not null or empty.

This prevents a `NoSuchElementException` from being thrown when `chain.first()`
is called on an empty chain, and ensures we instead throw an
`IllegalArgumentException` as expected by the `X509TrustManager` contract.

Tests were updated to provide an array containing a dummy X509Certificate mock
instead of `emptyArray()` to prevent these validation checks from failing
unintentionally during the delegation tests.

Co-authored-by: aww-aww <2776327+aww-aww@users.noreply.github.com>
Fix empty cert chain handling in TrustManagers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant