144 Commits
Author SHA1 Message Date
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
Cory Benfield 48ef04e421 Better errors when we fail hostname verification (#165)
Motivation:

We've noticed that the errors you get when hostname verification fail
are a bit gross, and don't tell you much. Users deserve to know more.

Modifications:

- Added a new extensible error type.
- Threw the new error with more diagnostics after verification failed.
- Removed a weird holdover from the old days of Swift.

Result:

Better error messages.
2019-12-12 15:55:32 +00:00
George Barnett daf6e8ea04 Add missing cases to == for NIOSSLError and BoringSSLError (#163)
Motivation:

Some error types were missing cases in their `==` implementation.

Modifications:

- Add missing cases to NIOSSLError and BoringSSLError

Result:

Better equality checking
2019-12-11 09:49:34 +00:00
Johannes Weiss 97972dc8af tests: remove unused varible (#162)
Motivation:

Warnings are bad and newer Swift compilers find more stuff.

Modification:

Remove unused variable.

Result:

Fewer warnings.
2019-12-10 13:05:16 +00:00
Johannes Weiss 77d5c44783 test lots of closes (#161)
Motivation:

A large number of closes in quick succession is a place where races
aren't entirely unlikely as the SSL handler, the Channel, and the
ChannelPipeline are all moving targets.

Modification:

Add a quick test doing 20 closes in one run.

Result:

More test coverage.
2019-12-09 16:56:20 +00:00
Cory Benfield b015dcbe87 Add regression limits for allocation tests. (#160)
Motivation:

We missed these out, which means we failed to detect the massive
allocation win in #159.

Modifications:

Correctly add allocation limits.

Result:

We'll know if we regress.
2.4.5
2019-12-04 17:06:24 +00:00
Cory Benfield 7b2e7cfe8c Update BoringSSL to 134fb89c4f9da7903d9aa81c6bd1d3c466782de1 (#159) 2019-12-04 12:04:20 +00:00
George Barnett 67f7af80d7 Update Code of Conduct project maintainer email address (#157)
Motivation:

The code-of-conduct email address is out-of-date.

Modifications:

Update code-of-conduct email address to swift-server-conduct@group.apple.com

Result:

- Code of conduct email address is up-to-date.
2019-12-02 14:11:11 +00:00
Cory Benfield 620a9140e8 Refactor doUnbufferWrites reduce memory pressure (#155)
Motivation:

The current implementation of doUnbufferWrites has the unfortunate habit
of both causing a substantial amount of ARC traffic and also allocating
a promise for all writes, even when one isn't necessary. Worse, if there
are many promises in a single set of flushes then we will also have to
allocate a future callback to cascade each result. All of this leads to
excessive pressure on the memory systems in Swift.

Modifications:

Refactor the code to avoid excessive use of closures, reducing ARC.
Rewrite promise chaining to reduce allocations of closure contexts and
promises.

Result:

Better performance in doUnbufferWrites
2019-12-02 10:28:52 +00:00
Cory Benfield a8dbd07f42 Add benchmarks. (#154)
Motivation:

When working with performance its useful to know what your approximate
throughput is. One of the ways we find this out in NIO is to add
benchmarks that let you know what the approximate runtime of a simple
sample program is. NIOSSL doesn't have any of these: it should.

Modifications:

Bring across the benchmark framework from other NIO projects.
Add two benchmarks mirroring the proposed allocation counter tests.

Result:

Insight into performance.
2019-12-02 09:39:02 +00:00
tomer doron e5c7a18a91 add harness for performance tests (#156)
motivation: run performance tests 🎉

changes: add performance-test task in docker-compose setup, add script to analyze performance results to be used in CI
2019-12-02 09:20:11 +00:00
Cory Benfield b0a34dbc69 Add allocation counter tests. (#153)
Motivation:

To do proper performance work it's necessary to have insight into what
programs are actually doing. One of the two major axes the SwiftNIO
project uses to measure is heap allocations. Currently swift-nio-ssl has
no introspection of heap allocations, so doing informed performance work
is very hard.

Modifications:

- Added the allocation counter test framework.
- Added two allocation counter tests.

Result:

Better idea of what's going on in heap allocations.
2019-12-02 09:00:15 +00:00
Cory Benfield f2ac69d154 Add regression test for executable stacks. (#152)
Motivation:

We want the CI to make sure we don't accidentally regress the executable
stack property of the binary.

Modifications:

Run execstack against our build output in the integration tests.

Result:

We shouldn't regress the executable stacks.
2019-11-26 09:50:39 +00:00
Cory Benfield ccf96bbe65 Add cross-compilation to symbol mangling. (#150)
Motivation:

BoringSSL potentially defines different symbols on different
architecture and platform combinations. This means that we've
historically missed mangling some symbol names when our script only
involved building on macOS.

We should build on more platforms to test this.

Modifications:

- Added support for cross compiling to Linux amd64, Linux aarch64, and
    Linux armv7 in symbol mangling script.
- Added support for compiling for iOS armv6 and arm64 in symbol mangling
    script.

Result:

Harder to run the mangling script, better results when you do.
2.4.4
2019-11-13 18:40:43 +00:00
Cory Benfield 63e61ed857 Update BoringSSL to 6ba98ff60144f60aba589b4d6121689528fbae76 (#149) 2019-11-13 15:04:17 +00:00
Johannes Weiss c277611ec3 enable TSan in CI (#145) 2019-10-25 01:28:55 -07:00
Cory Benfield e5c1af45ac Remove NIO 2.9.0 build warnings. (#144)
Motivation:

We were one of the few first-party users of
writeWithUnsafeMutableWritableBytes, and so we hit some build warnings.
We should use the nice interface to request the number of bytes we
actually want.

Modifications:

- Remove build warnings.
- Correctly ask to read a whole SSL record instead of a fragment of one.

Result:

Better code
2.4.3
2019-10-23 17:24:01 -07:00
Cory Benfield 37cbb1653c Clean up pointer API usage. (#143)
Motivation:

We are skirting to the edge of correctness on the pointer APIs, so we
should keep an eye on them and clean things up from time to time.

Modifications:

- Don't type cast a ByteBuffer pointer in tests.
- Use some buffer pointer APIs

Result:

Slightly better pointer usage.
2019-10-22 10:23:17 -07:00
Cory Benfield bd235c580b Update BoringSSL to 4ca15d5dcbe6e8051a4654df7c971ea8307abfe0 (#142) 2.4.2 2019-10-10 13:36:50 +01:00
Will Lisac 8a5135cce9 Fix BoringSSL compilation on aarch64 ARM Linux (#141) 2019-10-10 10:35:55 +01:00
tomer doron 0ec8dcf248 api breakage detection (#138)
motivation: test for api breakage on PR

changes:

* add script to detect api breakage
* amend docker setup to include jq
* amend docker-compose setup to include a shell utility task
2019-10-07 15:00:16 -07:00