Skip to content

Add SPKI certificate pinning support#910

Open
o-nnerb wants to merge 40 commits into
swift-server:mainfrom
o-nnerb:main
Open

Add SPKI certificate pinning support#910
o-nnerb wants to merge 40 commits into
swift-server:mainfrom
o-nnerb:main

Conversation

@o-nnerb

@o-nnerb o-nnerb commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

This PR introduces SPKI-based certificate pinning to AsyncHTTPClient to mitigate MITM attacks and compromised CAs.

Highlights:

  • Implements .strict and .audit modes with multi-algorithm hashing (SHA-256/384/512) and constant-time comparison.
  • Aligned with OWASP/NIST security standards, featuring rotation safety warnings and explicit error handling.
  • Requirement: Requires OpenSSL/BoringSSL backend (Network.framework connections ignore pinning configuration).

o-nnerb and others added 30 commits February 1, 2026 18:37
@o-nnerb

o-nnerb commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

@czechboy0 @FranzBusch can you review this?

@FranzBusch FranzBusch requested review from Lukasa and glbrntt June 23, 2026 12:41

@glbrntt glbrntt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks! This mostly looks good but I left some feedback inline which needs addressing.

Comment thread Sources/AsyncHTTPClient/ConnectionPool/ChannelHandler/SPKIPinningHandler.swift Outdated
Comment thread Sources/AsyncHTTPClient/AsyncAwait/HTTPClientRequest.swift
Comment thread Sources/AsyncHTTPClient/ConnectionPool/ChannelHandler/SPKIPinningHandler.swift Outdated
Comment thread Sources/AsyncHTTPClient/ConnectionPool/ChannelHandler/SPKIPinningHandler.swift Outdated
Comment thread Tests/AsyncHTTPClientTests/AsyncAwaitEndToEndTests.swift Outdated
Comment thread Sources/AsyncHTTPClient/ConnectionPool/ChannelHandler/SPKIPinningHandler.swift Outdated
Comment thread Tests/AsyncHTTPClientTests/SPKIHashTests.swift Outdated
Comment thread Tests/AsyncHTTPClientTests/AsyncAwaitEndToEndTests.swift Outdated
Comment thread Tests/AsyncHTTPClientTests/SPKIPinningTests.swift Outdated
@o-nnerb o-nnerb requested a review from glbrntt June 24, 2026 19:30

@glbrntt glbrntt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is looking good, just a couple of small things left. The e2e tests are much better now as well 👍

Comment thread Sources/AsyncHTTPClient/ConnectionPool/ChannelHandler/SPKIPinningHandler.swift Outdated
Comment thread Sources/AsyncHTTPClient/ConnectionPool/ChannelHandler/SPKIPinningHandler.swift Outdated
@glbrntt glbrntt added the 🆕 semver/minor Adds new public API. label Jun 25, 2026
@o-nnerb o-nnerb requested a review from glbrntt June 25, 2026 11:00

@glbrntt glbrntt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, this looks great! I would like @Lukasa to have a look before this is merged though.

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