Skip to content
This repository was archived by the owner on Aug 11, 2020. It is now read-only.
This repository was archived by the owner on Aug 11, 2020. It is now read-only.

QUIC as a native addon (secondary option) #371

Open
@jasnell

Description

@jasnell

Just opening this for discussion purposes. Because of the challenges presented by OpenSSL deciding not to land the QUIC related APIs until at least OpenSSL 3.1 (which likely won't happen until 2021 or 2022), the Node.js TSC has expressed some reluctance on landing the QUIC support in core because of the need to float patches on the OpenSSL 1.1.1 version that we ship. The key issues are that (a) the patches will need to be maintained for every 1.1.1 version bump, (b) anyone using openssl via shared library will not be able to use QUIC, and (c) the QUIC implementation would be forced to remain experimental until OpenSSL did officially support QUIC and could be forced to change should OpenSSL decide to go with a different API design than what BoringSSL has adopted.

Therefore, one of the possible paths forward here is to re-implement the QUIC support as a native add-on that statically links it's own modified OpenSSLrather than using core's.

I have started a separate project moving in that direction but there are a number of key challenges stemming from the number of core APIs we are using that are not available via N-API. These aren't difficult or impossible challenges to overcome, but combined they are non-trivial.

  • While we do not use the TLS/SSLWrap implementation from node_crypto, we do make use of SecureContext, which is, of course, backed by the OpenSSL version used by Core. As a standalone native addon with it's own separate linked version of OpenSSL, we shouldn't rely on core's SecureContext and instead should have an equivalent backed by the addons OpenSSL.

  • The implementation builds directly on UDPWrap and StreamBase, neither of which have N-API equivalents and both of which are guarded by NODE_WANT_INTERNALS). This is not a challenge if we just simply use NODE_WANT_INTERNALS=1 but then we bind ourselves to Node.js internals and fall into the traditional brittle native addon trap that N-API was meant to solve. We also make use of many of the utility macros, types, and functions that are scattered throughout core's internals (Debug, string encoding, Buffer, CHECK, AllocatedBuffer, AliasedArray, http_common, etc). All of which is guarded by NODE_WANT_INTERNALS and not exposed in any way via N-API.

  • This one is obvious... the addon would need it's own linked OpenSSL. This certainly should be possible but presents a number of challenges given how non-trivial the OpenSSL maintenance and build can be. We would end up duplicating much of the build dev that's currently in core to support it.

The native addon approach is certainly possible, and I already have a project scaffolded out in a repo that I can make public if folks want to help move things in that direction. There are certainly advantages to the addon approach in that the implementation would not be forced to be experimental for potentially years and could be made to work on existing LTS versions of Node.js. The plus side of having it as a native addon should not be discounted at all. If we can find good solutions to the above challenges, then I'm happy to move things in that direction.

/cc @mcollina @addaleax @bnoordhuis

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions