* Update vendoring and perlasm
* Update vendoring script
* Update to BoringSSL 3309ca66385ecb0c37f1ac1be9f88712e25aa8ec
* Handle API break in BoringSSL
Motivation:
Now that Swift 5.9 is GM we should update the supported versions and
remove 5.6
Modifications:
* Update `Package.swift`
* Remove `#if swift(>=5.7)` guards
* Delete the 5.6 docker compose file and make a 5.10 one
* Update docs
Result:
Remove support for Swift 5.6, add 5.10
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.
* NIOSSLHandler.close(mode: .output) new behaviour
Modifications:
* flush outstanding messages on NIOSSLHandler.close(mode: .output)
* change state once NIOSSLHandler.close(mode: .output) is invoked, so
that subsequent writes to the channel fail
* write integration tests to verify the behaviour
* * replace ConnectionState.closedOutput with ConnectionState.active(.output)
* Revert "* replace ConnectionState.closedOutput with ConnectionState.active(.output)"
This reverts commit 59cf0dfa147dcb794639b6a2dcd5331b7250c39f.
* close(mode: .output): perform TLS shutdown
* Insight comments from Cory about why test fail
Reason:
* atm our `NIOSSLServerHandler` does not support half-closure, thus it
closes TCP connection entirely on reception of close
-> our tests race
* Add temporary test demonstrating how half closure works for vanilla TCP connections
* testSubsequentWritesFailAfterCloseModeOutput: configure test server with allowRemoteHalfClosure
* First implementation of half-closure for NIOSSLServerHandlers
* NIOSSLHandler: throw ChannelError.outputClosed on NIOSSLHandler.bufferWrite
* Refactor
* Replace inputClosed: Bool with ConnectionState.inputClosed
* Add NIOSSLIntegrationTest.testMultipleCLoseOutput()
* Trigger TCP close when NIOSSLHandler.state == .inputClose
* testCloseModeOutputTriggersFlush: add allowHalfClosure to serverChannel
* * don't cache value of ChannelOptions.allowRemoteHalfClosure in NIOSSLHandler
* Refactor
* Refactor TCP input close handling
Modifications:
* send user event "input closed" onwards when in state .closed or .idle
* trigger closure of TCP input once we enter the .inputClosed state
* Refactor closingOutput procedure
Modifications:
* in `closeOuput` trigger the shutdown step regardless of the existence
of a promise
* remove redundant state transition to `.outputClosed`
* * closeOutput: flush before we doShutdown
* Refactor closeOutput state management
Modifications:
* remove `.closingOutput` state
* * closeOutput: remove closeOutputPromise
* * remove TCP half close example
* * add comment about not closing the entire channel after a half-closure
* * rework .inputClosed and .outputClosed state
* * add test for closing server output and client output
* Review Cory
Modifications:
* pass on user inbound event "input closed" to the next `ChannelHandler`
event in the event of an error
* cache value of `ChannelOptions.allowRemoteHalfClosure` across
`doFlushReadData` to avoid races in case the option's value
changes while `doFlushReadData` is being executed
* change behaviour: pass `closeOutputPromise` on in `context.close(mode:
.output, promise: closeOutputPromise`
* Review Cory
Modifications:
* `NIOSSLHandler.userInboundInputClosedTriggered`: execute
`fireErrorCaught` before `userInboundEventTriggered(.inputClosed)`
* `func completedAdditionalPeerCertificateVerification` fails with
invalid state when in states `{.input,.ouput}closed`
* Support close(.output) when handshaking
Modifications:
* create `enum BufferedAction` that allows `NIOSSLHandler` to buffer
actions instead of just writes
* rename `bufferedWrites` -> `bufferdActions`
* add `BufferedAction.closeOutput`, which allows us to buffer
invocations of `close(mode: .output)` when we are still in non-active
modes such as `.handshaking` or `.additionalVerification` -> this
means we'll invoke the closing of the output after our handshaking
step is completed and all our buffered writes have been flushed
* Review Cory
Modifications:
* Refactoring
* fixed wrong comment
* remove `MarkedCircularBuffer.forEachElementUntilMark()`
* discard all buffered actions that occured after the `.closeOutput`
buffered actions in `NIOSSLHandler.doUnbufferActions()`
* Fix race caused by setting .inputClosed
Motivation:
Previously we did not check the current state when setting the
`NIOSSLHandler`'s state to `.inputClosed`. This resulted in an issue
where when we were in state `.closing`, then set the state to
`.inputClosed`, we would end up with a fatalError in our shutdown /
scheduledShutdown as state `.inputClosed` is not a shutting-down state.
Modifications:
* check current state before setting `state = .inputClosed`,
specifically not setting the state to `.inputClosed` when we are
already in the process of doing a full closure
* NIOSSLHandler: full close if input & output closed
Modifications:
* `NIOSSLHandler`: escalate to full closure when both input and output
are closed
* `NIOSSLIntegrationTest.testCloseModeOutputServerAndClient`: assert
that having input and output closed in `NIOSSLHandler` results in full
closure
* `NIOSSLIntegrationTest.testCloseModeOutputServerAndClient`: assert
that if one side closes its output, the other side of the connection
closes its input
* Review Cory
Modifications:
* update comment on why we don't do a full channel close when we execute
`doShutDownStep` for state `.outputClosed`
* do not suppress error in `NIOSSLHandler.doUnbufferActions` when in
state `.outputClosed`
### Motivation
`swift-nio` has deprecated `NIOPreconcurrencySendable` in `2.51.0`. Removing the protocol conformance would be an API breaking change. Keeping the conformance is low cost and not worth the risk.
### Changes
- replace `NIOPreconcurrencySendable` with underscore version `_NIOPreconcurrencySendable`
### Result
We compile again with the latest `swift-nio` release without warnings
* 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
Motivation:
SwiftNIO periodically drops support for older Swift versions. Now that
5.7 has been released, 5.4 will be dropped.
Modifications:
- Remove 5.4 specific Package.swift and docker-compose
- Update the 5.7 docker-compose to use the released 5.7 and move from
focal (2004) to jammy (2204)
- Fix the tools version in Package@swift-5.5.swift
- Update docs
Results:
Minimum Swift version is 5.5
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.
* Adopt `Sendable`
* `@preconcurrency typealias` doesn’t work
* `NIOPSKClient/ServerIdentityCallback`
* `NIOSSLKeyLogCallback`
* `NIOSSLClientTLSProvider`
* Fix warnings in tests
* `@preconcurrency` is broken https://github.com/apple/swift/issues/60508
I think we don’t actually need it in that case and still don’t break API
* Fix warnigns in tets
* fix nightly
* Add file path and line number info to BoringSSL error wrappers
* Rename filename to filepath
* Renamed boringSSLErrorCode to boringSSLErrorInfo
* Store line number as Uint
* Change Int32 to Int
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
* 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>
Motivation:
Add TLS-PSK Support to address #230.
Modifications:
Modified SSLContext to take a passed in PSK callback to perform key and identity operations during the handshake.
Result:
TLS-PSK support for TLS 1.2. TLS 1.3 is not addressed due to API support in BoringSSL.
Motivation:
Unnecessary empty writes should be avoided, and we should avoid
completing promises too often.
Modifications:
- Avoid sending a split promise on every write when writes are too big.
- Avoid sending a zero-length write when writes are too big.
Result:
Slightly better write behaviour.
Note that this is fundamentally un-testable: there's no place to put a
test hook here, and we coalesce writes on the far side, so we can't do
much here.
Motivation:
TLSConfiguration cannot be made equatable due to its use of closures, so
we have our own best-effort functions. Unfortunately, I forgot to make
sure everything was added to them, so I'm doing so now.
Modifications:
- Add missing fields to bestEffort functions.
Result:
Better bestEffort functions.
Motivation:
In rare cases, users may attempt to write more data than can be
expressed in 2**31 bytes. This should not crash our program.
Modifications:
- Break up extremely long writes into smaller chunks
- Make sure to clamp on the read path too
Result:
Users who send hilariously long writes can do so.
# Motivation
We missed unbuffering reads after the handshake completed. This could result in reads that were buffered while the handshake was in progress to not unbuffer.
# Modification
This PR unbuffers any reads after the handshake is completed.
# Result
We are now unbuffering reads correctly.
* Various vendor script fixes:
- Fix various 'gsed' occurrences with '$sed'
- Remove the delocate patch, it is no longer required
- Add another patch to include inttypes in
CNIOBoringSSL/crypto/x509/t_x509.c where PRIu64 is used and remove it
from CNIOBoringSSL_bn.h. this works around a build failure with
xcodeproj.
- Use the host platform build directory when mangling C++ symbols
- Fix Python bytes/string writing in build-asm.py
* Update BoringSSL to c239ffd0552179f358de31517391679e9b62ccd3
* Include file path in `IOError`s thrown by `fopen`
* change error reason formatting and also include mode
* use explicit `String` to `UnsafePointer<CChar>` transformation
* Port SecureBytes from Swift Crypto to use with TLS-PSK
Motivation:
Porting SecureBytes to NIOSSLSecureBytes for using in (Add TLS-PSK Support #360).
Modifications:
Addition and modification of SecureBytes to work within SwiftNIO SSL.
Added additional test cases.
Result:
NIOSSLSecureBytes will be ported for usage in a later PR with TLS-PSK.
* secure-bytes-transfer: Added LinuxMain tests
* secure-bytes-transfer: Removed case from NIOSSLError
* secure-bytes-transfer: Addressed initial feedback
* secure-bytes-transfer: Removed NIOSSLSecureBytesError from SSLErrors
* secure-bytes-transfer: Remove public access from NIOSSLSecureBytes
* Remove remaining public declaration.
Co-authored-by: meaton2 <meaton3@apple.com>
Co-authored-by: Cory Benfield <lukasa@apple.com>
* support additional certificate validation
* run `scripts/generate_linux_tests.rb`
* fix review comments
- rename `CertificateChainVerificationCallback` to `AdditionalCertificateChainVerificationCallback`
- switch over `result` instead of try/catch
- add `. eofDuringAdditionalCertficiateChainValidation` error and throw it if channel becomes inactive while in `.additionalVerification` state
* add `Channel` parameter to `AdditionalCertificateChainVerificationCallback`
* get `context` from self instead of captering it
* save progress
* Only flush after handshake
* run `./scripts/generate_linux_tests.rb`
`
* Add NIOSSLCertficiateExtensions
* adopt naming of ObjectIdentifier
* address review comments
- namespace top level types with `NIO`
- add `withUnsafeBytes(_:)` that gives access to the buffer through an untyped buffer pointer
- fix indentation
* use real optional for `reference` in `_NIOSSLCertificateExtensions`
* fix review comments part 2
- nest `_Extensions` and `_Extension` under `NIOSSLCertificate`
- explain optional reference
- remove empty and copy constructor
- replace fancy force-unwraps with `!`
* use channel from argument
* fix review comments
- buffer the flush instead of ignoring it
- do not automatically flush after a succesfull handshake
* Add NIOSSLCertficiateExtensions
* adopt naming of ObjectIdentifier
* address review comments
- namespace top level types with `NIO`
- add `withUnsafeBytes(_:)` that gives access to the buffer through an untyped buffer pointer
- fix indentation
* use real optional for `reference` in `_NIOSSLCertificateExtensions`
* fix review comments part 2
- nest `_Extensions` and `_Extension` under `NIOSSLCertificate`
- explain optional reference
- remove empty and copy constructor
- replace fancy force-unwraps with `!`
* support additional certificate validation
* run `scripts/generate_linux_tests.rb`
* fix review comments
- rename `CertificateChainVerificationCallback` to `AdditionalCertificateChainVerificationCallback`
- switch over `result` instead of try/catch
- add `. eofDuringAdditionalCertficiateChainValidation` error and throw it if channel becomes inactive while in `.additionalVerification` state
* add `Channel` parameter to `AdditionalCertificateChainVerificationCallback`
* get `context` from self instead of captering it
Co-authored-by: Cory Benfield <lukasa@apple.com>
As correctly reported by the nightly compiler, this function appears to
be generic but has a same-type requirement that means it's actually not
generic.
* make `_SubjectAlternativeNames` and related types public
and add `RandomAccessCollection` conformance to `_SubjectAlternativeNames`
* move type conversion out of collection
* add `_SubjectAlternativeName`, `. NameType` and `. Contents`
* remove new error case
* add email as a supported name type
* fix review comments and move _SubjectAlternativeNames and related types to a separate file
* remove unused error code
* fix review comments
* add missing Glibc import for `in_addr` and related functionality
* add bounds check and use load instead of memoryRebound
* Enhancement to address issue-337 to query the final `TLSVersion`
Motivation:
To provide an enhancment to resolve issue-337 to query the final `TSLVersion`.
This allows a client channel to grab the final TLSVersion used for the connection.
Modifications:
Added extension points to allow querying the `TLSVersion` from the `SSLConnection` based on the `Channel` and `ChannelPipeline`.
Added an `unknown` type to `TLSVersion` to account for a default case where the `TLSVersion` cannot be derived from the conenction.
Added a unit test `testObtainingTLSVersionOnClientChannel` to query the final `TLSVersion` when the client channel is closed.
Result:
2 APIs added to query the `TLSVersion` when on a channel.
Additional Notes:
Note that I have 2 concerns about this PR that I would like some additional feedback on:
1. First is the `unknown` case for `TLSVersion`. This may not be needed as BoringSSL may just return `tlsv12` each time the version cannot be derived from the connection. Let me know your thoughts.
2. I am not wild about the way this is being unit-tested, but I wanted to do it this way because it provides the `TLSVersion` on the `Channel` after it is closed. Let me know your thoughts.
* Removed unknown case as it cases an API breakage.
Motivation:
Removed unknown case as it cases an API breakage.
Modifications:
Defaulted to tlsv12 as this is what BoringSSL will default to.
Result:
Wiped out unknown and switched to tlsv12 as the default
* issue--337: Fix failure on soundness.sh for Linux test
* issue-337: Addressed feedback from review
* issue-337: Updated PR to address feedback
* issue-337: Updated the EventLoopFuture for the Channel extension
* issue-337: Refactored test case
Co-authored-by: meaton2 <meaton3@apple.com>