Skip to content

Commit 698744f

Browse files
committed
android: additional comments for CertificateVerifier.kt
This commit add some additional comments to the `CertificateVerifier.kt` implementation based on the Android developer docs. In particular: * A note about the return from `checkServerTrusted` being a list ordered from EE to trust anchor. * A note that after adding a `PKIXRevocationChecker` to a `PKIXParameters` it can't be modified further or the effects of the modifications will be ignored. * A note about why `isRevocationEnabled` is set to false on the `PKIXRevocationChecker`.
1 parent f837ae6 commit 698744f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

android/rustls-platform-verifier/src/main/java/org/rustls/platformverifier/CertificateVerifier.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ internal object CertificateVerifier {
247247
// hostname verifier. Additionally, even the RFC 2818 verifier is not available until API 24.
248248
//
249249
// `serverName` is only used for pinning/CT requirements.
250+
//
251+
// Returns the "the properly ordered chain used for verification as a list of X509Certificates.",
252+
// meaning a list from end-entity certificate to trust-anchor.
250253
val validChain = try {
251254
trustManager.checkServerTrusted(certificateChain.toTypedArray(), authMethod, serverName)
252255
} catch (e: CertificateException) {
@@ -317,7 +320,13 @@ internal object CertificateVerifier {
317320
}
318321

319322
// Use the custom revocation definition.
323+
// "Note that when a `PKIXRevocationChecker` is added to `PKIXParameters`, it clones the `PKIXRevocationChecker`;
324+
// thus any subsequent modifications to the `PKIXRevocationChecker` have no effect."
325+
// - https://developer.android.com/reference/java/security/cert/PKIXRevocationChecker
320326
parameters.certPathCheckers = listOf(revocationChecker)
327+
// "When supplying a revocation checker in this manner, it will be used to check revocation
328+
// irrespective of the setting of the `RevocationEnabled` flag."
329+
// - https://developer.android.com/reference/java/security/cert/PKIXRevocationChecker
321330
parameters.isRevocationEnabled = false
322331

323332
// Validate the revocation status of all non-root certificates in the chain.

0 commit comments

Comments
 (0)