Commit Graph
362 Commits
Author SHA1 Message Date
Rick Newton-Rogers f4cae55577 Enable warnings as errors on Swift 6.0
Motivation:

Enable warnings as errors on Swift 6.0 to lock-in strict concurrency
safety.

Modifications:

Enable warnings as errors on Swift 6.0 to lock-in strict concurrency
safety.

Result:

CI will fail if we encounter strict concurrency warnings on Swift 6.0
2025-04-08 08:26:50 +01:00
Rick Newton-Rogers 71d303922f Enable macOS CI on pull requests (#517)
Motivation:

* Improve test coverage

Modifications:

Enable macOS CI to be run on pull request commits and make the use of
the nightly runner pool for main.yml jobs explicit.

Result:

Improved test coverage.
2025-04-01 17:42:30 +01:00
Rick Newton-Rogers fccff7bf59 Enable macOS CI on merge to main and daily timer (#516)
Motivation:

* Improve test coverage
* Check test pass/fail status
* Monitor CI throughput

Modifications:

Enable macOS CI to be run on all merges to main and on a daily timer.

Result:

Improved test coverage run out-of-band at the moment so we can get a
feeling for if any changes need to be made in the repo or in the CI
pipelines to ensure timely and stable checks.
2025-03-28 14:30:09 +00:00
Honza Dvorsky f5a8495acd Update the allocations count benchmark threshold for nightly-main (#514)
## Summary

Allocations regressed by 3 around Feb 2, 2025. While that's being
investigated, let's get CI back to green by bumping the threshold
temporarily.

## Test Plan

CI should pass again.
2025-03-10 13:25:27 +00:00
Rick Newton-Rogers d18e5a1442 Only apply standard swift settings on valid targets (#513)
Only apply standard swift settings on valid targets. The current check
ignores plugins but that is not comprehensive enough.
2025-03-07 15:07:00 +00:00
Rick Newton-Rogers abde2d8a6c Delete Thresholds/nightly-6.1 symlink (#512)
Following on from https://github.com/apple/swift-nio-ssl/pull/511 delete
`Thresholds/nightly-6.1` which is no longer needed now that the shared
benchmarks workflow has been updated
2025-03-07 12:10:51 +00:00
Rick Newton-Rogers ad730525ec move nightly-next thresholds and add legacy symlink (#511)
Move nightly-next thresholds and add legacy symlink; see
https://github.com/apple/swift-nio/pull/3122
2025-03-03 15:42:59 +00:00
Rick Newton-Rogers 46b12f0a9b Rename nightly_6_1 params to nightly_next (#510)
Rename nightly_6_1 params to nightly_next; see
https://github.com/apple/swift-nio/pull/3122
2025-03-03 14:37:17 +00:00
Cory Benfield 049520bf7d Update BoringSSL to 817ab07ebb53da35afea409ab9328f578492832d (#506)
This PR updates BoringSSL to a newer commit.

Relatedly, this also lifts our minimum C++ version to C++17, to match
BoringSSL.
2025-02-10 15:43:01 +00:00
Cory Benfield 0cc3528ff4 Update tools version to 5.9 (#508)
Motivation:

When we dropped 5.8 support we didn't raise the tools version. The
result is that 5.8 compilers still resolve newer versions, including
2.29.1. Unfortunately, 2.29.1 doesn't compile.

Modifications:

Lift the tools version to 5.9

Result:

Users won't accidentally resolve this from 5.8.
2.29.3
2025-02-05 19:45:31 +00:00
Rick Newton-RogersandCory Benfield b4a26ae126 CI use 6.1 nightlies (#504)
CI use 6.1 nightlies now that Swift development is happening in the 6.1
branch

Co-authored-by: Cory Benfield <lukasa@apple.com>
2.29.1
2025-01-30 14:53:03 +00:00
Rick Newton-Rogers d137b0c229 update benchmark thresholds to nightly 6.1 (#505) 2025-01-30 14:38:30 +00:00
Cory Benfield 86c5e87676 Add explicit import of NIOCore (#503)
Motivation:

Nightly CI builders need all the imports to be correct, and we were
missing a NIOCore import in the tests.

Modifications:

import NIOCore

Result:

Nice builds in the 6.1 nightlies
2025-01-29 19:07:23 +00:00
Cory Benfield 94d63e782b Actually disable hostname validation on Apple platforms when asked (#502)
Motivation:

swift-nio-ssl has long had a flag to disable its own certificate
validation behaviour. This flag works fine, and had the desired effect.

However, this flag did not take account of the fact that
Security.framework _also_ validates the hostname. Due to an
implementation bug, setting .noHostnameVerification disabled only one of
the two checks.

Modifications:

- Correctly check the flag before passing a hostname to
Security.framework
- Write some tests to make sure the behaviour works in all modes.

Result:

Better, more consistent behaviour.
2025-01-03 09:36:35 +00:00
Franz Busch 0c49639a2b Update release.yml (#501)
Update the release.yml file with the latest label changes
2024-12-18 13:30:33 +01:00
Cory Benfield bdd5269d0c Fix issues compiling on nightly-main image (#500) 2024-12-18 11:06:08 +00:00
Cory Benfield 3cb4d5ad12 Correctly override connection state using sslContextCallback (#499)
Motivation:

The sslContextCallback overrides modify the SSL_CTX object itself.
That's not useful: in addition to having a global effect, which is
rarely what we want, certain modifications don't apply that late, and
setting the credentials is one of them. The result is that the callback
didn't actually do anything. Not that useful.

Modifications:

- Extract the cert chain setting functions from NIOSSLContext and move
them to general-purpose functions.
- Add support there for calling them on a SSL * as well as on a SSL_CTX
*
- Call them in an override function on SSLConnection
- Call that!
- Add a bunch of tests.

Result:

The callback actually does what it should.
2024-12-18 10:57:06 +00:00
Gus CairoandCory Benfield 9fc482815c Update expired test certificate (#498)
Co-authored-by: Cory Benfield <lukasa@apple.com>
2024-12-17 11:20:45 +00:00
Rick Newton-Rogers 4f5bd82c56 Enable MemberImportVisibility check on all targets (#497)
Enable MemberImportVisibility check on all targets. Use a standard
string header and footer to bracket the new block for ease of updating
in the future with scripts.
2024-12-17 11:08:42 +00:00
Cory Benfield e252d9bf14 Update BoringSSL to 9559c4566a6d12194c42db5f3dbbcb5de35cfec2 (#496)
This patch updates BoringSSL.
2024-12-09 16:48:49 +00:00
Cory Benfield 3ee8d53556 Update BoringSSL to 059585c8dadc7c8170c788f8c89843ee1c5b8f11 (#495) 2024-11-28 16:10:21 +00:00
Franz Busch ea402d2629 Aligning semantic version label check name (#494) 2024-11-28 12:05:42 +00:00
Rick Newton-Rogers 5f317df0d2 remove unused Swift 6 language mode workflow (#491)
remove unused Swift 6 language mode workflow
2024-11-15 09:57:07 +00:00
Rick Newton-Rogers 1bab54a11e add .editorconfig file (#490)
add .editorconfig file
2024-11-15 09:52:50 +00:00
Gus Cairo c7e9542133 Add API to create PKCS#12 (#486)
## Motivation
It would be handy to provide an API to create PKCS#12 files from a list
of `NIOSSLCertificates` and a `NIOSSLPrivateKey`.
This would be particularly useful when dealing with
Network.framework/NIOTransportServices/Security.framework, which use
`SecIdentity`s for SSL. Two particular use cases are
https://github.com/apple/swift-nio-ssl/issues/484#issuecomment-2410375188
and `grpc-swift-nio-transport`, which would use this API for testing the
NIOTS transport implementation.

## Modifications
This PR adds a static method to `NIOSSLPKCS12Bundle` that creates a
PKCS#12 file from the given array of certificates + private key, and
returns it as an array of bytes.

## Result
PKCS#12 files can be created using NIOSSL.
2.29.2 2.29.0
2024-10-29 14:23:36 +00:00
Rick Newton-Rogers 8a6b89d9a4 Unify main.yml and scheduled.yml, remove 5_8 ref (#489)
### Motivation:

* `main.yml` and `scheduled.yml` are mostly duplicative.
* Scheduled runs failed because of a deprecated reference to a Swift 5.8
pipeline

### Modifications:

* Unify `main.yml` and `scheduled.yml`
* Remove the reference to the 5.8 pipeline

### Result:

Working scheduled runs.
2024-10-29 10:58:45 +00:00
Rick Newton-Rogers 75e5a978e8 Switch allocation benchmarks to GHA (#488)
### Motivation:

This will allow us to decommission the old CI hooks.

### Modifications:

* Migrate the existing tests to use the package-benchmark framework.
* Delete the obsolete integration tests
* Remove allocations test references from the docker files.

### Result:

Allocation counts are checked using GitHub Actions.
2024-10-25 16:17:41 +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
mads-frameo 27b25e29e7 Add support for supplying supported curves to TLSConfiguration (#485)
This PR adds the support to specify what ECs the handler supports when
doing the handshake.

```swift
var config = TLSConfiguration.makeClientConfiguration()
config.curves = [.x25519]
```
2024-10-18 15:41:46 +01:00
Cory Benfield d7ceaf0e4d Update BoringSSL to d0a175601b9e180ce58cb1e33649057f5c484146 (#483)
This patch has 3 parts: a commit to update the vendoring script, a
commit that contains the results of running the script, and then a fixup
for the API breaks we got.
2.28.0
2024-10-09 18:11:48 +01:00
Rick Newton-Rogers aa68d49ddf Update expired test certificate (#482)
Update expired test certificate.

### Motivation:

An expired test certificate was causing tests to fail.

### Modifications:

Updated the test certificate.

### Result:

Tests should pass.
2024-10-03 08:40:16 +01:00
Andrew BarbaandCory Benfield e9021d1a4e Implement SSL_CTX_set_cert_cb (#456)
This is a first pass at reviving
https://github.com/apple/swift-nio-ssl/pull/311 in order to fix
https://github.com/apple/swift-nio-ssl/issues/310

Credit to @TechnikEmpire, I did my best to address the comments in the
original PR from @Lukasa

If the approach looks okay I'll move to testing

---------

Co-authored-by: Cory Benfield <lukasa@apple.com>
2024-09-16 12:26:04 +01:00
George Barnett d1088ebe07 Exclude privacy manifest when it isn't a resource (#480)
Motivation:

swift build warns when the privacy manifest isn't a package resource.

Modifications:

- Add it do the excluded files when it isn't a resource

Result:

- Resolves #466
2024-09-09 10:09:27 +01:00
Franz Busch fa0d30f367 Add release.yml (#479) 2024-09-06 12:56:08 +01:00
c7eef9ed36 Modify TLS PSK API to handle the case when no hint is provided by the server (#452)
Hello,

As I was trying to implement some HTTP calls using `async-http-client`
and TLS-PSK authentication, I realised that my server was not sending
any PSK hint.

The actual implementation of the clientPSKCallback makes the server psk
hint mandatory.
Similarly the implementation of the serverPSKCallback makes the server
hint mandatory.

Reading
[RFC4279](https://datatracker.ietf.org/doc/html/rfc4279#section-5.2) it
seems that on the opposite the server psk hint should be provided only
on application that mandate it.


> [5.2](https://datatracker.ietf.org/doc/html/rfc4279#section-5.2).
Identity Hint
>    In the absence of an application profile specification specifying
>    otherwise, servers SHOULD NOT provide an identity hint and clients
>    MUST ignore the identity hint field.  Applications that do use this
>    field MUST specify its contents, how the value is chosen by the TLS
>    server, and what the TLS client is expected to do with the value.

I made this PR to provide an empty string to the callbacks in the case
the server doesn't provide one.
Providing an optional might be a better solution in term of semantic but
it would break the API.

---------

Co-authored-by: Martial Lienert <mlienert@netatmo.com>
Co-authored-by: Cory Benfield <lukasa@apple.com>
2024-08-22 17:01:27 +01:00
George Barnett 7b84abbdce Avoid a spin loop when inactive is fired before active (#470)
Motivation:

The NIOSSLHandler can enter a spin loop in `doUnbufferActions` if
writing data into BoringSSL fails with SSL_ERROR_WANT_READ or
SSL_ERROR_WANT_WRITE.

One way these errors can happen is if a write into BoringSSL happens
prior to the handshake completing. The NIOSSLHandler is explicit about
starting the handshake: it's done in channel active and in handler added
if the channel is already active.

However, the handshaking step is currently done without any state
checking, so if the state is 'closed' (as it would be after channel
inactive) then the handshake will still start. This can happen if
channel inactive happens before channel active.

To reach the write loop there must be a buffered write and flush prior
to the handshake step starting and the state isn't 'idle' or
'handshaking'. This can happen if a write and flush hapens while
'NIOSSLHandler' is in 'channelActive' (it forwards the 'channelActive'
event _before_ starting the handshake) and 'channelInactive' came first.

Modifications:

- Early exit from 'doHandshakeStep' if the state isn't applicable for
starting a handshake.
- Don't buffer writes when the state is 'closed' as they'll never
succeed and can be failed immediately.
- If the write isn't succesful in 'doUnbufferActions' then either write
to the network or try reading.
- Only allow a limited number of spins through 'doUnbufferActions'

Result:

- Resolves https://github.com/apple/swift-nio-ssl/issues/467
2.27.2
2024-08-19 10:26:01 +01:00
George Barnett 4086c44c2c Update test cert (#476)
Motivation:

Some of the test certs expired so some tests are failing.

Modifications:

Update the test certs

Result:

Tests pass
2024-08-13 15:38:40 +01:00
Cory Benfield a40a74e693 Stop using symlinks for PrivacyInfo (#475)
Motivation:

Per @jakepetroules, swift-build copies symlinks as-is into resource
bundles. That means these symlinks are dead when built with swift-build.
There's sort of no point in that.

Modifications:

Remove symlinks, replace with files.

Result:

Privacy info works.
2024-08-13 08:14:28 +01:00
Ayush Garg a9fa5efd86 Mark .file case deprecated for NIOSSLPrivateKeySource (#474)
swift-nio-ssl expects file to in specific format when loading the PrivateKey from a file baed on the extension of the file. This is prone to errors, since there is no standard agreement on the extension and format of the file. 
An example of a mismatch is `.key` swift-nio-ssl tries to load such file as DER, though these can be in PEM format too.

We could based on the binary contents of the file provided infer the format of the file, but it doesn't seem like a logic this library should own. The clients should be able to load the file themselves. 

In this PR  `.file` case is marked deprecated and relevant deprecation flags and documentation is added to point to the preferred option.
2.27.1
2024-07-29 03:10:26 -07:00
LamTrinh.Dev 62c9086897 Update swiftlang link in Package.swift (#472)
Update the new link from "https://github.com/apple/swift-docc-plugin" to "https://github.com/swiftlang/swift-docc-plugin.git"
2024-07-23 02:08:59 -07:00
MK 2c1178831a Fix incorrect filename (#471)
PR #459 added this privacy manifest, but refers to it by the wrong name here.
2024-07-22 00:26:14 -07:00
George Barnett 21fda641da Update certs for testing (#469)
Motivation:

A leaf certificate used for testing certificate verification only on
Darwin platforms had expired.

Modifications:

Update the cert

Result:

Tests pass
2024-07-19 06:14:39 -07:00
finagolfin 3eec6698d3 Use Bionic module and new Android overlay in Swift 6 (#468) 2024-07-15 09:52:21 +01:00
Nicolas Bachschmidt 2b09805797 Use case-insensitive comparison when validating cert domain name (#464) 2.27.0 2024-05-15 13:58:50 -07:00
Johannes Weiss 023c9d2435 test compiler version not language version (#462) 2024-05-09 13:00:09 +01:00
Clinton Nkwocha 45cb3bac27 Handle error when private key file type is unknown (#460)
Motivation:

When the private key file for a TLS configuration has an unknown type, the program crashes. Hence, users are unable to catch the error.

Modifications:

A new error was added to `NIOSSLExtraError` and the program throws that error instead of crashing.

Result:

The program now throws an error instead of crashing.
2024-05-01 16:47:11 +01:00
George Barnett 2d9c63d16f Add empty privacy manifest (#459)
Motivation:

NIOSSL distributes a copy of BoringSSL, which means it needs a privacy
manifest.

Modifications:

- Add a privacy manifest

Result:

NIOSSL shouldn't be rejected from app submission by not declaring a
privacy manifest.
2024-04-09 08:04:43 +01:00
d7840f36ad fix https fail on Android (#453)
* fix https fail on Android

* add compatibility for https failure after Android14

---------

Co-authored-by: wangxiang13 <wangxiang13@lixiang.com>
Co-authored-by: Cory Benfield <lukasa@apple.com>
2024-03-26 14:39:01 +00:00
George Barnett 3b2a01c9de Raise minimum Swift version to 5.8 (#458) 2024-03-11 08:50:45 +00:00
David Nadoba 7613886ed9 Update expired apple.com leaf certificate in tests (#457) 2024-02-13 23:16:42 +00:00