Motivation:
Telling Github what's vendored makes all stats better.
Modifications:
Tell github that Sources/CNIOBoringSSL is vendored.
Result:
Better stats.
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.
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
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.
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.
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.
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.
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.
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.
Motivation:
Some error types were missing cases in their `==` implementation.
Modifications:
- Add missing cases to NIOSSLError and BoringSSLError
Result:
Better equality checking
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.
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.
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.
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
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.
motivation: run performance tests 🎉
changes: add performance-test task in docker-compose setup, add script to analyze performance results to be used in CI
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.
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.
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.
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
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.
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
Motivation:
Well-formed Linux assembly code declares a .note.GNU-stack section in
order to help out the linker. When absent, the linker makes some
suboptimal linking decisions that can cause pain in running programs.
Modifications:
- Amend the vendoring script to add the .note.GNU-stack section to all
assembly files on Linux.
- Updated BoringSSL
Results:
Better linker behaviour.
* swift 5.1 docker setup
motivation: support swift 5.1
changes:
* use formal swift docker images
* refactor docker-compose to seperate unit tests, integration tests and full test suites
* add docker compose file for swift 5.1, will add CI job once merged
* update swiftformat version to 0.40.12
Motivation:
Our scripts have code to catch the functions that are used with STACK_OF
and LHASH_OF data structures in BoringSSL in order to namespace them.
Sadly, some declarations were falling through the cracks: we missed some
LHASH_OF functions used internally, and we missed the
DEFINE_NAMED_STACK_OF macro used for a new C++ data type.
Modifications:
- Improved these scripts to catch more cases.
- Updated BoringSSL to 9806ae005b3085683a2fcf2953e4170893e0973d.
Result:
Fewer exported symbols from BoringSSL.
Motivation:
The BoringSSL version of `BIO_new_mem_buf` takes a const buffer but
we pass a mutable one.
Modifications:
Pass a const buffer.
Result:
Unsafe instead of Unsafe+Mutable.
Motivation:
On different platforms C may define `int` and `unsigned` to be different
types. When writing C interop code in Swift it's preferable to
use the `CInt` and `CUnsignedInt` typealiases as they will resolve to
the correct C type on all supported platforms. If the imported C API is
a definite-sized type, like `uint32_t` we leave the Swift type as
definitely-sized.
Modifications:
Use `CInt` instead of `Int32` for C `int` parameters and `CUnsignedInt`
instead of `UInt32` for C `unsigned` parameters.
Result:
Code is more portable and definite-sized types stand out.
Motivation:
The underlying BoringSSL BIO APIs used by NIOSSLCertificate,
NIOSSLPrivateKey take a raw byte buffer and a count,
and do not need the input buffers to be NUL-terminated. However, the API
currently takes an `Array<Int8>` (which is a typealias of `Array<CChar>` on
platforms where NIO is primarily developed). This suggests an incorrect
completion in Xcode (`utf8CString`) which includes a trailing NUL byte.
In fact, all of the NIOSSL unit tests make this mistake. The more common
use case of creating a these types from a `Data`, `ByteBuffer`, or
`String.UTF8View` is made more awkward as these are easy to convert to
`[UInt8]` but harder to convert to `[CChar]` without extending them with
an unnessary NUL byte.
Modifications:
Add new `bytes:` overloads to the convenience initializers and deprecate
the `buffer:` convenience initalizers. Use these new initializers in the
unit tests.
Result:
A more ergnomic way to correctly create these types from `Data`,
`ByteBuffer`, and `String.UTF8View`.
Motivation:
The README uses the '.file' case of 'NIOSSLCertificateSource' which has
been deprecated.
Modifications:
Update the README to use the recommended replacement method:
'fromPEMFile(_:)'.
Result:
The README no longer uses a deprecated enum case.
Motivation:
It is only possible to load multiple certificates from a PEM file,
sometimes it is useful to load multiple certificates from a buffer.
Modifications:
- Deprecate the `.file` source of loading a certificate, since it would
only load the first certificate in a file.
- Provide methods for loading multiple certificates from a PEM file or
buffer.
Result:
Multiple certificates can be loaded from a PEM file/buffer.
Motivation:
When including an xcodeproj generated by SwiftPM (which builds
CNIOBoringSSL) into an xcodeproj which wasn't generated by SwiftPM it
doesn't know about the correct header paths.
Modifications:
Update the vendor-boringssl script to:
- Namespace BoringSSL with CNIOBoringSSL_ instead of CNIOBoringSSL/
- Create an umbrealla CNIOBoringSSL header
- Apply a patch to replace inttypes.h with sys/types.h in bn.h
- Apply a patch to conditionally include arm_arch.h
BoringSSL was also updated to: ae223d6138807a13006342edfeef32e813246b39
Result:
Non-SwiftPM xcodeproj's can build a SwiftPM generated xcodeproj
which includes CNIOBoringSSL.
Motivation:
Previously, if the user tried to open a private key that had a password
but didn't specify one, we would just crash.
Modifications:
Throw an error instead of crashing if no password was supplied but one
was needed.
Result:
Fewer crashes.
Motivation:
The README suggested that configuration, SSL context, and the SSL
handler should be created in three lines following each other. That
leads to people copy & pasting this into the root of their `main.swift`
and then by accident reusing the SSL handler which leads to pretty bad
issues.
Modifications:
Make the README snippet clearer and closer to an actual usage.
Result:
API used more correctly.
Motivation:
If we don't import CNIOBoringSSL @_implementationOnly, then some details
of libssl's C structs might leak into NIOSSL's ABI which might lead to
clashes further down the line.
Modification:
- make all CNIOBoringSSL(Shims) imports @_implementationOnly
- remove all concrete libssl types from instance variables
Result:
- fixes#116
- works around SR-11125
Motivation:
While TLS renegotiation is in general a bad idea, it is widely used for
delayed TLS-based client authentication. We are able to support this
use-case, and so we should enable it.
As with BoringSSL, we'd like to continue to default to not supporting
this mode of operation. However, users are free to enable support if
they so choose.
Modifications:
- Added flags for configuring renegotiation.
- Added integration test harness.
- Added renegotiation integration test with s_server.
- Added renegotiation and client cert support to sample client.
Result:
Users will be able to perform TLS renegotiation.
Motivation:
The 32-bit assembly in BoringSSL doesn't assemble correctly on 32-bit
apple platforms. It took us a while to notice because we previously
haven't had any supported 32-bit platforms. NIOSSL still doesn't really
support any 32-bit Apple platforms, as all production use on those
platforms should use NIOTS, but there's no excuse for the compilation
failures really.
Modifications:
Remove assembly acceleration on 32-bit Apple platforms.
Result:
Better compilation on 32-bit Apple platforms.