Skip to content

Issues/91 change certstore caching#96

Closed
marek-ch wants to merge 5 commits into
issues/94-remove-option-useChallenge-2from
issues/91-change-certstore-caching
Closed

Issues/91 change certstore caching#96
marek-ch wants to merge 5 commits into
issues/94-remove-option-useChallenge-2from
issues/91-change-certstore-caching

Conversation

@marek-ch
Copy link
Copy Markdown
Contributor

Closes #91

@marek-ch marek-ch self-assigned this Apr 17, 2026
@marek-ch marek-ch requested review from TomasKypta and Copilot and removed request for TomasKypta April 17, 2026 12:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates CertStore’s caching behavior so that a successful server update replaces the locally cached certificates with exactly what the server returned (after filtering), fixing the case where deleted server certificates were previously retained in cache.

Changes:

  • Change update processing to rebuild the cached certificate list from the server response (filtering expired, skipping duplicates), instead of merging into the existing cache.
  • Adjust the internal cache-update helper to persist only the newly produced CachedData.
  • Add unit tests covering cache replacement, filtering of expired response entries, and response de-duplication.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
library/src/main/java/com/wultra/android/sslpinning/CertStore.kt Reworks update-time cache construction to replace (not merge) cached certificates and updates related log messaging.
library/src/test/java/com/wultra/android/sslpinning/CertStoreUpdateTest.kt Adds tests validating the new “replace cache” behavior plus filtering/deduplication expectations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread library/src/test/java/com/wultra/android/sslpinning/CertStoreUpdateTest.kt Outdated
@marek-ch marek-ch force-pushed the issues/94-remove-option-useChallenge-2 branch from 7879950 to 276f2bc Compare April 20, 2026 15:08
@marek-ch marek-ch force-pushed the issues/91-change-certstore-caching branch 4 times, most recently from ebec779 to 9c938d5 Compare April 21, 2026 09:32
@marek-ch marek-ch force-pushed the issues/94-remove-option-useChallenge-2 branch from 00886ad to c886dd9 Compare April 21, 2026 11:28
@marek-ch marek-ch force-pushed the issues/91-change-certstore-caching branch from 5b1723f to 9baef75 Compare April 21, 2026 11:28
@marek-ch marek-ch force-pushed the issues/91-change-certstore-caching branch from 9baef75 to a108ed7 Compare April 21, 2026 11:54
@marek-ch marek-ch requested a review from kober32 April 21, 2026 11:54
Copy link
Copy Markdown
Member

@kober32 kober32 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK, consider my 2 remarks - nothing serious but could be improved


@Synchronized
internal fun updateCachedData(update: (CachedData?) -> CachedData?) {
internal fun updateCachedData(update: () -> CachedData?) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't we just pass the data instead of the closure? Without the parameter, it doesn't serve the purpose anymore

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, I've refactored it

@Synchronized
internal fun updateCachedData(update: (CachedData?) -> CachedData?) {
internal fun updateCachedData(update: () -> CachedData?) {
restoreCache()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think restoreCache is no longer needed since we throw away the cache on line 155 anyway, and never use it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have renamed cacheIsLoaded -> isFallbackCacheLoaded.. we need to restore the cache prior to setting it in case the update is null, so there is at least fallback in cache ready

@marek-ch
Copy link
Copy Markdown
Contributor Author

due to merge conflicts this PR is closed and new one is created
#98

@marek-ch marek-ch closed this Apr 24, 2026
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.

3 participants