Skip to content

Deprecate NIOSSLCertificate(file:format:)#550

Merged
glbrntt merged 2 commits intoapple:mainfrom
glbrntt:deprecate-init
Jul 15, 2025
Merged

Deprecate NIOSSLCertificate(file:format:)#550
glbrntt merged 2 commits intoapple:mainfrom
glbrntt:deprecate-init

Conversation

@glbrntt
Copy link
Contributor

@glbrntt glbrntt commented Jul 15, 2025

Motivation:

NIOSSLCertificate has an 'init' which loads a single cert from PEM or
DER encoded file. This, obviously, only loads the first PEM which is
very rarely what users actually want to do. This is a common source of
error when loading cert chains and is easy to miss in review.

Modifications:

  • Deprecate the init and point users to the fromPEMBytes method for
    PEM which returns an array of certs, and to a new fromDERBytes which
    returns a single cert.

Result:

Harder to misuse API

glbrntt added 2 commits July 15, 2025 08:39
Motivation:

NIOSSLCertificate has an 'init' which loads a single cert from PEM or
DER encoded file. This, obviously, only loads the first PEM which is
very rarely what users actually want to do. This is a common source of
error when loading cert chains and is easy to miss in review.

Modifications:

- Deprecate the init and point users to the `fromPEMBytes` method for
  PEM which returns an array of certs, and to a new `fromDERBytes` which
  returns a single cert.

Result:

Harder to misuse API
@glbrntt glbrntt added the 🆕 semver/minor Adds new public API. label Jul 15, 2025
@glbrntt glbrntt marked this pull request as ready for review July 15, 2025 09:33
@glbrntt glbrntt enabled auto-merge (squash) July 15, 2025 12:18
@glbrntt glbrntt merged commit 5108dbd into apple:main Jul 15, 2025
41 checks passed
glbrntt added a commit to glbrntt/swift-nio-ssl that referenced this pull request Jul 15, 2025
Motivation:

In apple#550 a use of `NIOSSLCertificafe(file:format:)` was replaced with
`NIOSSLCertificafe.loadPEMFile(_:).first`, which isn't necessarily the
same (the error flow is different for one). To avoid any subtle
behaioral changes revert back to the old API in that one instance.

Modifications:

- Use old API

Result:

Fewer behavioural changes
glbrntt added a commit that referenced this pull request Jul 15, 2025
Motivation:

In #550 a use of `NIOSSLCertificafe(file:format:)` was replaced with
`NIOSSLCertificafe.loadPEMFile(_:).first`, which isn't necessarily the
same (the error flow is different for one). To avoid any subtle
behaioral changes revert back to the old API in that one instance.

Modifications:

- Use old API

Result:

Fewer behavioural changes
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