Skip to content

Custom certificate store #256

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

brimworks
Copy link

This change adds support for implementing a CustomCertificateStore in a backwards compatible way with minimal impact to performance. A custom certificate store can be implemented, and then the new CertificateStore(custom:) constructor can be used so that the custom certificate store can be used interchangeably with a "normal" certificate store.

Additionally, a test case verifies that this new protocol will work for our use case. More specifically, the use case we have is for normalization of distinguished names so that an exact match of distinguished names is no longer required. For example, if printableString should be used interchangeably with a utf8String.

This pull request has two commits:

  • One that adds support for a CustomCertificateStore
  • One that modifies the implementation to support async lookup of certificiates.

The second change is not required for our use-case, however I would expect that there may be a future use-case that requires looking up certificates in a database, and supporting an async protocol would be valuable. Also, the verify() method is already async, so supporting an async lookup does not disrupt any existing public APIs.

brimworks added 2 commits June 9, 2025 12:36
This new protocol allows one to customize the logic for matching an
issuer to the subject certificate authority.
This change would allow for certificates to be dynamically looked up in
a database.
@Lukasa Lukasa added the 🆕 semver/minor Adds new public API. label Jun 13, 2025
Copy link
Contributor

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

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

Awesome, this looks really good. Left a small nit in the diff.


@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
extension CertificateStore.Resolved {
@usableFromInline
Copy link
Contributor

Choose a reason for hiding this comment

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

These may as well also become @inlinable.

Copy link
Author

Choose a reason for hiding this comment

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

Good call. I've updated as such.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 semver/minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants