164 Commits
Author SHA1 Message Date
Cory Benfield cc0e80dbcc Update BoringSSL to 67818bea6690a230e2f42e8a588e0f54949bbbf1 (#244) 2.9.2 2020-09-30 13:27:21 +01:00
Cory Benfield 4c66baf51d We use the main branch now. (#243) 2020-09-25 20:25:03 +01:00
Cory Benfield 3f26a3e8a1 Swift 5.3-RELEASE is out, let's use it. (#241) 2020-09-21 10:07:16 +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
George Barnett ea1dfd6419 Update BoringSSL to 1c58648f14ed75f2a8cc3ae08897987d97f493ec (#239)
* Update patch-2-arm-arch.patch

* Update BoringSSL to 1c58648f14ed75f2a8cc3ae08897987d97f493ec
2.9.1
2020-08-26 16:17:22 +01:00
Daniel Alm 7932e709af Fix the -f option in build_podspec.sh. (#237)
* Fix the -f option in build_podspec.sh.

* Add docs.

* Another minor tweak.
2020-08-06 18:23:50 +01:00
Cory Benfield 8a137b72a9 Update BoringSSL to 54858b63c1d886f6c8d903d4a4f594f1485de189 (#235) 2.9.0 2020-07-24 11:43:48 +01:00
Peter Adams 7efa8a714f Don't install Jazzy on Xenial (#234)
Motivation:

Ruby on Xenial is too old for the cocoapods downloader which jazzy uses.

Modifications:

Change Dockerfile to not install Jazzy on xenial.

Result:

Dockerfile will build again, but bionic or later is required for docs.
2020-07-21 18:05:48 +01:00
Cory Benfield 3a012b89cf Fix inappropriate language in NIOSSL (#233)
Motivation:

It's also 2020 in NIOSSL, and just like in NIO, there's no good reason
to use exclusionary terminology when perfectly good alternatives exist.

Modifications:

Removed exclusionary language.

Result:

Clearer codebase.
2020-07-10 08:53:16 +01:00
Matthias Bartelmeß b94f2b6297 Add option to specify signining and verification algorithms (#232)
Motivation:

BoringSSLs built-in list of valid signing and verification algortihms is not
always the one you actually would like to use. For example adding or removing
algorithms from this list might increase compatibility as well as security

Modifications:

Add an option to set CNIOBoringSSL_SSL_CTX_set_verify_algorithm_prefs
and CNIOBoringSSL_SSL_CTX_set_signing_algorithm_prefs

Result:

The user can set signing and verification algortihms at their will
2020-07-09 15:47:13 +01:00
George Barnett d381bc53ed Silence #file/#filePath warnings in XCTest (#228)
Motivation:

Swift 5.3 warns when `#file` is passed to a function expecting
`#filePath` even though the values are currently the same.

- apple/swift#32445
- https://bugs.swift.org/browse/SR-12936
- https://bugs.swift.org/browse/SR-12934
- https://bugs.swift.org/browse/SR-13041

Modifications:

- Wrap `file` in parentheses to silence warnings.

Result:

- No warnings, uglier code
2.8.0
2020-06-30 15:16:01 +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
Cory Benfield f0b118d9af Allow double-setting the custom verify callback. (#224)
Motivation:

An unnecessary assertion prevented us double-setting the custom verify
callback. This had the effect of making the custom verify callback
unusable on Apple platforms in debug mode only. The actual code
tolerates a double-setting of the custom verify callback just fine, but
the assertion prevents it for no good reason.

Modifications:

- Removed an assertion.
- Added some tests to confirm it's all fine.

Result:

Users won't get crashes when they try to use the custom verify callback.
Fixes #223.
2.7.5
2020-06-11 12:26:37 +01:00
George Barnett e14f8ebd6a Add synchronous option to trunk push in build_podspec.sh (#222)
See https://github.com/apple/swift-nio/pull/1551
2020-06-10 15:23:13 +01:00
George Barnett a44a343f69 Update build_podspec.sh to not use exact dependency versions (#221)
Motivation:

The build_podspec.sh script generates a podspec which requires exact
versions of its dependencies. This very quickly turns into unresolvable
dependency graphs.

Modifications:

NIO version passed to script must be in the format MAJOR.MINOR
Podspec dependencies are now '>= MAJOR.MINOR', '< MAJOR+1'

Result:

Looser version requirements for podspecs
2020-06-10 13:51:32 +01:00
Cory Benfield 9cb641037b Enable X509_V_FLAG_TRUSTED_FIRST. (#220)
Motivation:

Unfortunately, while BoringSSL is mostly a fundamentally fantastic
library, it has inherited OpenSSL's X509 verifier. This verifier has a
number of issues, but its biggest problem is that it's simply not great
at verifying certificates!

Certificate chains are not so much "chains" as they are a single path
through a DAG. There are potentially many possible paths from a leaf
certificate to a set of roots. Some of these paths are not trusted, some
may be. BoringSSL's default verifier does not do a good job in some edge
cases because it prefers to use the intermediates provided by the client
when it could do a better job by using its own trust store.

As an example, consider the following three-certificate "chain":

CA A -- signs -- Intermediate CA B -- signs -- Leaf C

Imagine that CA A now becomes untrusted, either because it was revoked
or (more topically) because it expires. Imagine also that, in the
meantime, Intermediate CA B has become a fully-fledged CA, and has
re-issued its certificate as a self-signed root using the same key and
identifier.

The mistaken resolver may attempt to use as many certificates as
possible from the peer chain. If the peer chain is using the old,
now-replaced intermediate CA, this will cause BoringSSL to get confused:
it will build a chain that chains up to the intermediate CA, find the
old root in the trust store, and then complain that that root is expired
and fail the validation.

Instead, we want to ignore the intermediate CA B altogether! This is
because we now have a trusted root B', and if we use that then we'll
instantly get a valid chain and can move on.

This behaviour is controlled by a flag, `X509_V_FLAG_TRUSTED_FIRST`.
This flag is set by default in OpenSSL 1.1+. Sadly, it is not set by
default in BoringSSL. This patch resolves that issue.

Note that this issue only affects non-Apple platforms. On Apple
platforms we use the system resolver, which does not have this issue.

Modifications:

- Set `X509_V_FLAG_TRUSTED_FIRST`.
- Add a test to verify that flag is set.

Result:

We'll do a better (but still bad) job of building trust chains.
2.7.4
2020-06-04 20:39:42 +01:00
Cory Benfield ea1498d4d5 Update BoringSSL to 53a17f55247101105ae35767d5c5a6c311843a8e. (#218) 2020-06-02 08:53:34 +01:00
43d3753cf8 link swift-nio-extras in docs (#208)
Co-authored-by: Cory Benfield <lukasa@apple.com>
Co-authored-by: George Barnett <gbarnett@apple.com>
2020-05-19 12:10:06 +01:00
Cory Benfield 10e0e17dd4 Resolve exclusivity violation on connection teardown. (#217)
Motivation:

When we're failing promises on channelInactive, we do so while holding
the write buffer mutably. This means that if anyone calls write() on us,
we'll explode, as we enqueue the write into the buffer.

Modifications:

- Rewrote the close loop to not hold the write buffer mutably.
- Added a regression test.

Result:

No crashes in production.
2.7.3
2020-05-14 18:13:27 +01:00
Cory Benfield f6ad7f7ef1 Update BoringSSL to 7c522995d1ea5386b3223a19b0f62e73c1f76b17 (#216)
Also remove a temporary BoringSSL patch and deal with no C files being
in fiat/
2020-05-13 11:10:35 +01:00
tomer doron 67303bd6d8 improve 5.3 docker setup (#214)
motivation: pin to 5.3 nighties 

changes: use swiftlang/swift:nightly-5.3-master-bionic instead of swiftlang/swift:nightly-master-bionic
2.7.2
2020-05-05 08:49:53 +01:00
Johannes WeissandCory Benfield e0049a1600 @_implementationOnly also for Swift 5.3 (#212)
Motivation:

@_implementationOnly also works in Swift 5.3, let's use it.

Modification:

Use @_implementationOnly for Swift 5.1 ... 5.3

Result:

Proper 5.3 support.

Co-authored-by: Cory Benfield <lukasa@apple.com>
2020-05-01 08:01:28 +01:00
Cory Benfield f02ae1bd04 Fix broken docker installation (#209) 2020-05-01 07:11:37 +01:00
Cory Benfield e806aee7a6 Address some flaky tests. (#213)
Motivation:

We had a few flaky tests that have been blocking CI runs. This fixes
some of them.

Modifications:

Avoid some timing weirdness around trying to grab errors.
Allow fewer writes than we require.

Result:

Less flakiness!

Resolves #177
Resolves #204
2020-04-30 16:40:56 +01:00
Cory Benfield ae213938e1 Unwrapping timeout shouldn't close channel. (#206)
Motivation:

If the unwrapping timeout fires, rather than close the channel we should
just fire an error down the pipeline. This is in-line with standard NIO
behaviour, and allows users to opt-out of channel closure in the event
that they need it.

Modifications:

- Internal state modification to have different behaviour when
    unwrapping and closing timeout fires.

Result:

Users can control what happens if unwrapping times out.
2.7.1
2020-03-26 15:04:20 +00:00
Cory Benfield 711564e9cc Unwrapping TLS should still time out. (#205)
Motivation:

When we added TLS "unwrapping" support (that is, taking a NIOSSLHandler)
and removing it from a pipeline without killing it, we never plumbed
through the timeout behaviour from close. This can lead to permanently
delayed unwraps where the unwrap never completes.

Modifications:

Take the existing support for timed out shutdown and plumb it through to
unwrapping as well.

Result:

Unwrapping TLS cannot get stuck.
2020-03-25 14:36:25 +00:00
Johannes Weiss 584c0d06c4 universal bootstrap support (#185) 2.7.0 2020-03-23 16:26:05 +00:00
Cory Benfield 7add274f6e Update BoringSSL to 5298ef99bf2b2d77600b3bb74dd572027bf495be (#200)
Note that the vendor script changed: BoringSSL added a new top-level
header that had to be added to the umbrella header.
2020-03-18 08:38:46 +00:00
Shekhar Rajak e2768829af Get rid of do { ... } catch { ... } for expected errors (#199) 2020-03-17 17:49:20 +00:00
Matt EatonandCory Benfield 1e932f59fa Fix for Unprocessed Data before Closing (#198)
Motivation:

Fix for issue #179 that resolves error: APPLICATION_DATA_ON_SHUTDOWN
when data is present on read path while closing.

Modifications:

Minor modification to channelRead and a unit test.

Result:

Closing read paths with data will no longer error.
Data will be processed and closed gracefully.

Co-authored-by: Cory Benfield <lukasa@apple.com>
2020-03-13 14:26:47 +00:00
Doug FriedmanandCory Benfield e9a9d87edb fix typo in README (#195)
Co-authored-by: Cory Benfield <lukasa@apple.com>
2020-03-04 16:04:20 +00:00
3613382784 Add Build Podspec Script (#193)
Co-authored-by: Jake Prickett <jpricke1@ford.com>
Co-authored-by: Johannes Weiss <johannesweiss@apple.com>
2020-03-03 22:25:44 +00:00
tomer doron f5bdb018d1 update docs generation script to work better with selinux (#194)
motivation: docs scripts is broken on selinux due to restriction on ssh-agent

changes:
* change the jazzy workspace to a directory accessible by the CI node so we can push from the agent instead of from the docker container
* dont remove older docs when pushing new ones
* add version information and source links
2020-02-28 12:25:52 -08:00
Jake PrickettandJake Prickett c388c564ab Adjust import to allow for CocoaPod support (#192)
Co-authored-by: Jake Prickett <jpricke1@ford.com>
2020-02-26 09:37:24 +00:00
Cory Benfield b99ca3a19a Mitigate Folly/BoringSSL static linking issue. (#191)
Motivation:

BoringSSL and Folly both attempt to play silly buggers with the sdallocx
symbol defined in jemalloc. Unfortunately, they don't play nicely
together, and the end result if you have both present is that BoringSSL
will reliably SIGBUS or SIGSEGV on initialization. Naturally, this isn't
good.

Modifications:

- Resolve the issue by patching out BoringSSL's allocator optimisation.
- Update BoringSSL to 6432bb46ab44731567ec923e6c8fc182f13d0070.

Result:

Flow and BoringSSL will play better together.
2020-02-24 14:41:27 +00:00
Matt Eaton 978e1ead99 Removed explicit Equatable implementations. (#187)
Motivation:

Finished removing explicit Equatable implementations
on BoringSSLError.

Modifications:

Removed explicit Equatable implementations.

Result:

Will allow Swift to synthesize equatable conformance for
BoringSSLError.
2020-02-21 16:19:39 +00: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
Matt Eaton 6ee46effd1 Swapped applicationProtocols check for encodedApplicationProtocols. (#184)
Motivation:

Resolution on issue-151.
Adding a README for NIOTLSServer.

Modifications:

Swapped applicationProtocols check with encodedApplicationProtocols.
Added a README for NIOTLSServer.
Altered the README for NIOSSLHTTP1Client.

Result:

Updated documentation and swapped ALPN checks during SSLContext
initialization.
2020-02-17 08:08:26 +00:00
David Evans af46d9b58f Replace deprecated function calls (#183) 2.6.2 2020-02-14 12:37:30 +00:00
Cory Benfield 978dfd6c9a Update BoringSSL to 21a879a78a60c8667468a9eba994c8365eaf92ea. (#182) 2.6.1 2020-02-12 13:51:22 +00:00
Johannes Weiss e61c217883 tell github that Sources/CNIOBoringSSL is vendored (#180)
Motivation:

Telling Github what's vendored makes all stats better.

Modifications:

Tell github that Sources/CNIOBoringSSL is vendored.

Result:

Better stats.
2020-02-05 15:05:43 +00:00
George Barnett 9d3d664955 Avoid curried thunks (workaround SR-12115) (#176)
Calling `function(otherFunction)` allocates, but
`function({ otherFunction($0) }` does not.

See: SR-12115 and SR-12116.

Modifications:

Avoid passing functions directly; pass them in new closures instead.

Result:

Fewer allocations.
2020-02-03 07:18:25 +00:00
tomer doron 0499d739b4 improve docker security (#178)
motivation: more secured ci setup

changes:
* enable :z selinux flag on bind mounts so we can enable selinux on ci
* drop potentially exploitable capabilities from docker-compose
2020-02-01 07:39:32 +00:00
Johannes Weiss cf54f5c1db enable @_implementationOnly for Swift 5.3 (#174) 2.6.0 2020-01-16 17:05:47 +00:00
Cory Benfield 75f7b54a5f Provide better certificate verification callback (#171)
Motivation:

We've exposed the OpenSSL certificate verify callback for a while now.
Unfortunately, this callback is fairly hostile to callers, as it is
called repeatedly through the certificate verification process, instead
of presenting the unified certificate chain to the user.

BoringSSL has a better verification callback available that we use
internally, but that is not exposed to users. It would be nice to give
users the better API.

Modifications:

- Expose the BoringSSL verification callback to users.
- Re-plumb the Security.framework verification to use our public API.

Result:

Easier certificate chain verification overrides.
2020-01-16 15:52:35 +00:00
Cory Benfield 5d459a0ea3 Add hashability to Certificate and PrivateKey (#169)
Motivation:

When types are equatable its important to ask why they aren't hashable.
In the case of SSLCertificate and SSLPrivateKey there isn't any
particuarly good reason. We should support it.

Modifications:

Added Hashability to NIOSSLCertificate and NIOSSLPrivateKey.
Fixed NIOSSLPrivateKey equatable implementation.

Result:

Hashable keys and certs.
2020-01-16 12:17:31 +00:00
Cory Benfield db0e8e457e Add API for dumping certificate bytes. (#172)
Motivation:

In some cases it's useful to be able to ask questions about what the
certificate looks like. We don't have a full X509 API, so the best way
to handle this for now is to allow users to extract the bytes of the
certificate so they can use other libraries to do the job.

Modifications:

- Added a function for dumping certificate bytes.

Result:

Users can have the certificate bytes.
2020-01-14 13:08:21 +00:00
Cory Benfield a2681681eb Allow testing deprecated functions. (#170)
Motivation:

If we want to deprecate anything, we either have to remove the tests or
enable testing deprecated functionality without warnings. Conveniently,
@weissi has already written a patch that enables this for swift-nio in
apple/swift-nio@c2c7250, so we can just port that across.

Modifications:

Port Johannes' patch and run it.

Result:

We can test deprecated code.
2020-01-14 09:34:20 +00:00
Cory Benfield 803cbead75 Update BoringSSL to 0deb91ab3f7e24307572497f0f7438684590bf92 (#167) 2020-01-07 18:02:13 +00:00
Cory Benfield b75ffaba05 Remove unsafe code from hostname verification (#166)
Motivation:

The hostname verification code operated on unsafe buffer pointers
without any clear justification for doing so. While it may have been
necessary to do that once, it certainly isn't necessary now.

Modifications:

Rewrite all the code to operate on Array.
Throw a more meaningful error.

Result:

Bounds checking, better safety.
2.5.0
2019-12-13 15:52:01 +00:00