18 Commits
Author SHA1 Message Date
Orhan Yigit Yazicilar 4a1819a281 Drop Swift 5.10 (#559)
### Motivation:

Swift 5.10 is no longer supported, we should bump the swift-tools
version.

### Modifications:

* Update Swift tools version to 6.0
* Correct the failing tests on macOS

### Result:

Code reflects our support window.
2025-09-25 13:45:48 +01:00
aryan-25 1d4afc64e8 Allow the peer's validated certificate chain to be returned in the custom verification handler (#553)
Motivation:

Users are currently able to register a custom callback in
`NIOSSLClientHandler` and `NIOSSLServerHandler` for verifiying the
certificates presented by the peer. However, there is no mechanism for
storing additional metadata for future use. This change adds support for
the peer's validated certificate chain to be returned from the custom
verification callback and later be accessed from the handler.

Modifications:

- Added a new custom verification callback type
`NIOSSLCustomVerificationCallbackWithMetadata`.
- This type is identical to the existing
`NIOSSLCustomVerificationCallback`, with the exception that callers must
complete the callback with a `NIOSSLVerificationResultWithMetadata`
(also introduced in this change). This result type can either be
initialized with no fields, or with a validated certificate chain.
- Added properties/methods to `NIOSSLHandler`, `Channel`, and
`ChannelPipeline` for accessing the validated certificate chain.

Result:

Users are now able to store the peer's validated certificate chain from
the custom verification callback and use the result downstream.
2025-08-21 12:55:53 +01:00
Rafael Cepeda f64263a41f Enabled -require-explicit-sendable compiler flag (#549)
Enabled -require-explicit-sendable compiler flag and fixed the errors
highlighted by the compiler.
2025-07-10 18:49:30 +01:00
Zane Enders 6df102a39c Fix typo in NIOSSLServerHandler documentation. (#534)
Motivation:

NIOSSLServerHandler miss named NIOSSLClientHandler in documentation.

Modifications:

Fix Typo.

Result:

Correct name in documentation.
2025-04-22 09:20:11 +00:00
Cory Benfield a6a52bf020 Remove some redundant suppressed conformances (#522)
These suppressed conformances are not necessary, as they are redundant
with the suppressed conformance on the parent class.
2025-04-11 11:09:24 +01:00
Rick Newton-Rogers 61cfaf9798 Migrate to GitHub Actions (#487)
Migrate CI to use GitHub Actions.

### Motivation:

To migrate to GitHub actions and centralised infrastructure.

### Modifications:

Changes of note:
* Disable warnings-as-errors until issues with recent NIO changes are
resolved
* Adopt swift-format using rules from SwiftNIO
* Remove scripts which are no longer needed

### Result:

Feature parity with old CI minus allocation tests which remain on the
old CI.
2024-10-25 09:32:23 +01:00
Cory Benfield 7aabfa3b64 Add support for shrinking massive ByteBufferBIOs (#443)
Motivation:

ByteBufferBIOs will grow their outbound buffer until flush is
called. They will retain their capacity at however large it got
to avoid reallocating, as they assume that your write pattern will
be fairly consistent.

In some cases this is a bad strategy, because it overcommits data.
To allow users to reclaim this data, we can add a configuration
option that will shrink the playload on the next write.

Modifications:

- Added support for ByteBufferBIO to shrink the payload.
- Plumbed up support for handler configuration.
- Tests that shrinkage actually works.

Result:

Users can reclaim memory.
2023-09-18 14:11:27 +01:00
Cory Benfield 5c57d8e64a Drop Swift 5.5 (#425)
* Drop Swift 5.5

This patch drops Swift 5.5 support. It removes docker-compose files and
deletes any conditional compilation guards that are no longer necessary.

* Remove test generation script
2023-04-13 16:48:55 +01:00
Cory Benfield 024bbd111e Remove giant write test (#398)
Motivation:

The giant write test requires an enormous commitment of RAM to run it.
This has caused problems for both our own CI and a number of downstream
CI systems, leading to long execution times or outright failures.

Unfortunately, we can't defend against the original failure using this
test suite, but we can at least exercise the new machinery we added and
trust that the configuration is right.

Modifications:

- Make the maximum write size configurable internally
- Test the maximum write size at a different value.

Result:

We feel confident that the write splitting continues to work correctly.
2022-09-02 12:03:19 +01:00
David Nadoba c5eaf16b33 Adopt Sendable incrementally (#392)
* Adopt `Sendable`

* `@preconcurrency typealias` doesn’t work
2022-08-11 10:35:14 +01:00
Cory Benfield 1b16a07692 Use Docc for documentation (#390)
Motivation

Documentation is nice, and we can help support users by providing useful
clear docs.

Modifications

Add Docc to 5.6 and later builds
Make sure symbol references work
Add overview docs

Result

Nice rendering docs
2022-08-09 08:33:58 +01:00
David NadobaandCory Benfield c37f562e0e Invoke additionalPeerCertificateVerificationCallback with peer certificate (#387)
* Invoke `NIOSSLContext.AdditionalCertificateChainVerificationCallback` with peer certificate and make it public without guaranteeing API stability

* move function typealias to the module namespace and improve documentation

* Move `additionalPeerCertificateVerificationCallback` from `NIOSSLContext` to `NIOSSHandler`

* make peer certificate non-optional in user callback

* Update Sources/NIOSSL/NIOSSLHandler.swift

Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-07-28 04:12:34 -07:00
Cory Benfield c359ba56f7 Clean up imports and dependencies (#319)
Motivation:

With NIO 2.32.0 we broke the core NIO module up into modules that split
apart the POSIX layer and the core abstractions. As a result, this
package no longer needs to express a hard dependency on the POSIX layer.

Modifications:

- Rewrote imports of NIO to NIOCore.
- Added NIOEmbedded and NIOPosix imports where necessary in tests.
- Extended soundness script to detect NIO imports.
- Note that the main modules still depend on NIO, which is necessary
for backwards-compatibility reasons. This dependency is unused.

Result:

No need to use NIOPosix.
2021-09-14 14:55:25 +01:00
Artem Redkin 8f53c5e059 Fixes a typo in deprecation message. (#240)
Motivation:
NIOSSLServerHandler does not have an init with
serverHostname argument, there is a typo in
deprecation message.

Modifications:
Fix a typo.

Result:
No more typo.
2020-09-08 15:00:58 +01:00
Cory Benfield 5a6ad123af Add support for custom verify callback to servers. (#226)
Motivation:

In #171 when we worked on providing access to the better verification
callback, we managed to entirely miss that we had not provided that
access to servers. This meant they were stuck only with the
substantially-less-useful old-school callback, instead of the much
better new-school one.

While we're here, as we had to add multiple new initializers to
NIOSSLServerHandler, I took the opportunity to also resolve the server
handler portion of #147. The issue itself is still open because the
client handlers still have throwing inits, but all "preferred"
initializers on NIOSSLServerHandler no longer throw.

Modifications:

- Deprecated NIOSSLServerHandler.init(context:verificationCallback:)
- Implemented two new initializers on NIOSSLServerHandler.
- Added tests to verify that the NIOSSLServerHandler verification
  callback is actually called.
- Removed all now-unnecessary try keywords.

Result:

Users will be able to provide custom verification callbacks that work
much better than they currently can when on the server, and the server
is now back into feature parity with the client.
2020-06-16 16:01:42 +01:00
Matt Eaton f5995ca784 Replace NIOSSLError.unableToAllocateBoringSSLObject with fatalError (#186)
Motivation:

Provides a resolution to issue-173.
deprecate & remove throw NIOSSLError.unableToAllocateBoringSSLObject;
replace by crash #173

Modifications:

Removed all NIOSSLError.unableToAllocateBoringSSLObject and replaced
with fatalError to force a crash.

Result:

In critical points where execution should not continue a fatalError
will be thrown instead of an NIOSSLError.unableToAllocateBoringSSLObject.
2020-02-20 14:05:16 +00:00
George Barnett 4f9d64ddd0 Add a timeout for TLS shutdown. (#100)
Motivation:

The remote peer may not always respond to a close notify. This would
leave the SSL handler waiting to shutdown. The shutdown should timeout
in these cases to ensure shutdown completes.

Modifications:

- Added a shutdown timeout to the NIOSSLHandler, and a configurable
  timeout amount to TLSConfiguration.
- Added a test to validate timing out a shutdown.

Result:

TLS shutdown will complete even if the remote peer does not respond to a
close notify.
2019-04-15 09:56:01 +01:00
Cory Benfield 45b1f82692 Rename everything. (#75)
Motivation:

Unfortunately, it turns out that the word "OpenSSL" just ended up everwhere
in our codebase, including in the names of our types. This was, in hindsight,
a bit of an unfortunate bit of naming.

We should take this breaking opportunity to give these types better names.
In particular, we should stop identifying them as belonging to any library
other than this one, "NIOSSL". That way we become somewhat independent of
the specific way that this library is implemented.

Modifications:

Renamed a bunch of stuff. Internal types mostly got their names changed
from OpenSSL->BoringSSL. External types generally got their names changed
to "NIOSSL", except where those types directly reflected a BoringSSL
implementation detail, specifically in the errors.

The main name changes are:

SSLContext -> NIOSSLContext
OpenSSLError -> BoringSSLError
NIOOpenSSLError -> NIOSSLError
OpenSSLInternalError -> BoringSSLInternalError
OpenSSLPKCS12Bundle -> NIOSSLPKCS12Bundle
OpenSSLPassphraseCallback -> NIOSSLPassphraseCallback
OpenSSLPassphraseSetter -> NIOSSLPassphraseSetter
OpenSSLPrivateKey -> NIOSSLPrivateKey
OpenSSLPublicKey -> NIOSSLPublicKey
OpenSSLCertificate -> NIOSSLCertificate
OpenSSLVerificationResult -> NIOSSLVerificationResult
OpenSSLVerificationCallback -> NIOSSLVerificationCallback
OpenSSLCertificateSource -> NIOSSLCertificateSource
OpenSSLPrivateKeySource -> NIOSSLPrivateKeySource
OpenSSLTrustRoots -> NIOSSLTrustRoots
OpenSSLSerializationFormats -> NIOSSLSerializationFormats
OpenSSLHandler -> NIOSSLHandler
OpenSSLClientHandler -> NIOSSLClientHandler
OpenSSLServerHandler -> NIOSSLServerHandler

Oh, and renamed the module too: it's now NIOSSL, instead of NIOOpenSSL.

Result:

Users have better names for things.
2019-03-01 17:25:33 +00:00