Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for TLS sockets #329

Closed
5 tasks done
yorickpeterse opened this issue Sep 11, 2022 · 15 comments
Closed
5 tasks done

Support for TLS sockets #329

yorickpeterse opened this issue Sep 11, 2022 · 15 comments
Assignees
Labels
feature New things to add to Inko, such as a new standard library module std Changes related to the standard library
Milestone

Comments

@yorickpeterse
Copy link
Collaborator

yorickpeterse commented Sep 11, 2022

Inko's sockets are just regular sockets, without any built-in support for TLS
(as in SSL/TLS, not thread-local storage). Combine that with the lack of
built-in support for various ciphers/cryptographic functions, and using
encrypted connections is a real challenge.

To make this possible, Inko should provide a TLS stack of some sort which can be
used with its non-blocking sockets. As first sight the best option may appear to
be using rustls and exposing it through
the VM. While this would likely save us time, I'm not a fan of it, for a few
reasons:

  • Our API would largely be dictated by the API exposed by rustls, and the
    resulting API may be annoying to use
  • We'd increase the number of VM/non-Inko dependencies, and I want to keep those
    to a minimum
  • A TLS stack requires various features/functions/etc we'd likely have to
    support anyway, such as cryptographic functions. Instead of exposing all that
    through the VM, I want to write as much in Inko as possible
  • We'd likely have to wrap various Rust types in raw pointers and heap allocate
    them. I'd like to keep this to a minimum, only using it where absolutely
    necessary

A first step towards this it to identify what exactly we'd need. After that we
need to figure out if there's some sort of shared test suite/reference we can
use to determine if we're implementing things correctly. The last thing I want
to do is implement this wrong.

Related issues:

Related links:

TODO:

  • Basic setup using rustls
  • Add std.base64, needed to parse PEM files
  • Add std.crypto.pem for parsing PEM files
  • Add std.crypto.x509 for defining basic certificate and private key types. For the time being these are just wrappers around a ByteArray
  • Change std.net.tls such that ClientConfig and ServerConfig accept Certificate and PrivateKey types instead of file paths, such that you can provide these from memory. The actual validation/parsing of the underlying data is still done by rustls
@yorickpeterse
Copy link
Collaborator Author

marked this issue as related to #283

@yorickpeterse yorickpeterse added feature New things to add to Inko, such as a new standard library module and removed type::feature labels Mar 15, 2023
@yorickpeterse yorickpeterse removed this from the 0.2.5 milestone Mar 15, 2023
@yorickpeterse yorickpeterse moved this to Planning in NLnet tasks Jun 6, 2023
@yorickpeterse yorickpeterse added this to the 0.17.0 milestone Jun 6, 2023
@yorickpeterse yorickpeterse self-assigned this Jun 6, 2023
@yorickpeterse
Copy link
Collaborator Author

yorickpeterse commented Jan 13, 2024

While the original desire was a pure Inko TLS stack, I'm currently leaning more towards just using OpenSSL 3.x instead. For one, writing such a stack is a massive effort. Second, it will probably be a long time before we can guarantee constant-time operations needed for various crypto bits, potentially opening us up for timing attacks until then.

Using OpenSSL does mean that cross-compilation becomes more of a challenge, whereas a pure Inko stack wouldn't suffer from this.

Of course wrapping rustls is still a promising option, and would probably make cross-compilation a heck of a lot easier.

@yorickpeterse
Copy link
Collaborator Author

Based on https://github.com/rustls/rustls/blob/main/examples/src/bin/simpleclient.rs, I think wrapping rustls shouldn't be too hard. Essentially TLS sockets would need to store three values: a file descriptor to the raw socket, the rustls wrapper reader/writer, and a reference to the rustls connection object.

@yorickpeterse
Copy link
Collaborator Author

https://github.com/fres621/inko-tls/ might prove useful as a reference.

@yorickpeterse
Copy link
Collaborator Author

Per the source code of rustls' Stream type (https://docs.rs/rustls/latest/src/rustls/stream.rs.html#11-17), it seems we can just create a Stream ad-hoc for every TLS read/write, instead of having to keep it around. This means that for a TLS socket we only need to persist a ClientConnection and ClientConfig somewhere.

@yorickpeterse yorickpeterse modified the milestones: 0.17.0, 0.16.0 Jul 4, 2024
@yorickpeterse
Copy link
Collaborator Author

Writing an entire TLS stack from scratch is going to be way too much work, and probably isn't a good idea to begin with as Inko has nothing to allow constant-time operations (as needed for correct encryption). As such, we'll start with basing TLS sockets on either OpenSSL or rustls, whichever works best.

@yorickpeterse yorickpeterse moved this from Pending to In Progress in NLnet tasks Jul 4, 2024
yorickpeterse added a commit that referenced this issue Jul 9, 2024
This fixes #329.

Changelog: added
yorickpeterse added a commit that referenced this issue Jul 10, 2024
This fixes #329.

Changelog: added
yorickpeterse added a commit that referenced this issue Jul 11, 2024
This fixes #329.

Changelog: added
yorickpeterse added a commit that referenced this issue Jul 11, 2024
This fixes #329.

Changelog: added
yorickpeterse added a commit that referenced this issue Jul 11, 2024
This fixes #329.

Changelog: added
yorickpeterse added a commit that referenced this issue Jul 11, 2024
This fixes #329.

Changelog: added
yorickpeterse added a commit that referenced this issue Jul 11, 2024
This fixes #329.

Changelog: added
yorickpeterse added a commit that referenced this issue Jul 13, 2024
This commit also changes std.net.socket.SocketAddress such that it no
longer stores IP address as a String, instead storing them as a proper
IpAddress instance. In addition, SocketAddress.new is removed in favour
of creating an instance of the class directly, as all fields are (and
will remain) public such that a dedicated "new" method is redundant.

This fixes #329.

Changelog: added
yorickpeterse added a commit that referenced this issue Jul 13, 2024
This commit also changes std.net.socket.SocketAddress such that it no
longer stores IP address as a String, instead storing them as a proper
IpAddress instance. In addition, SocketAddress.new is removed in favour
of creating an instance of the class directly, as all fields are (and
will remain) public such that a dedicated "new" method is redundant.

This fixes #329.

Changelog: added
yorickpeterse added a commit that referenced this issue Jul 13, 2024
This commit also changes std.net.socket.SocketAddress such that it no
longer stores IP address as a String, instead storing them as a proper
IpAddress instance. In addition, SocketAddress.new is removed in favour
of creating an instance of the class directly, as all fields are (and
will remain) public such that a dedicated "new" method is redundant.

This fixes #329.

Changelog: added
@yorickpeterse
Copy link
Collaborator Author

Regarding splitting libraries, I think that might actually make things worse: Rust doesn't have a stable ABI, so the separate TLS crate producing libinkotls.a would have to include the standard library as well. The result is that we end up linking with two .a libraries both including the exact same standard library code, resulting in an executable that's actually larger than when using a single library.

yorickpeterse added a commit that referenced this issue Jul 18, 2024
This adds the module std.net.tls and refactors std.net.socket in various
places, such that we can provide support for TLS 1.2 and TLS 1.3.

The TLS stack is backed by Rustls (https://github.com/rustls/rustls). My
original plan was to write the stack in Inko, but I deemed this far too
time consuming and not beneficial for users (compared to using an
existing mature stack). I also experimented with OpenSSL, but using
OpenSSL is like walking through a minefield, and its API is a pain to
use (in part due to its use of global and thread-local state).

Rustls is compiled such that it uses the "ring" backend instead of
aws-lc. This is done because aws-lc requires additional dependencies on
FreeBSD, and increases compile times significantly (about 30 seconds or
so). While performance of TLS 1.3 is less ideal when using ring compared
to using aws-lc (rustls/rustls#1751), it
should still be good enough (and still be much faster compared to using
OpenSSL).

A downside of using Rustls is that the executable sizes increase by
about 6 MiB (or 2 MiB when stripping them), due to the extra code
introduced by Rustls and its dependencies. Sadly we can't avoid this
unless we use OpenSSL, which introduces far more pressing issues.

This fixes #329.

Changelog: added
@yorickpeterse
Copy link
Collaborator Author

yorickpeterse commented Jul 18, 2024

It seems Rustls is doing some blocking IO under the hoods, which could mess up the scheduler/performance:

edit: to clarify, Rustls itself doesn't perform the blocking IO, but the underlying OS-specific routines used to verify certificates might.

@yorickpeterse
Copy link
Collaborator Author

To add to the above: this affects macOS and Windows, as both Linux and FreeBSD have a rather straightforward system that doesn't involve expensive IO calls under the hoods.

How a few languages handle this differs (here "OpenSSL" as the technique means it uses/mimics OpenSSL behaviour):

Language Technique
Node.js 🔴 OpenSSL
Go 🟢 System
Ruby 🔴 OpenSSL (as far as I can tell)
Python 🔴 OpenSSL, with a manual workaround
Deno 🟢 System, using this crate and this crate
Java 🟡 System, provided this is explicitly enabled, not sure about the default

Based on this (and assuming this pattern holds for other languages), it seems a little inconsistent as to what approach is used.

@yorickpeterse
Copy link
Collaborator Author

yorickpeterse commented Jul 19, 2024

The choices come down to the following:

  • rustls-platform-verifier: does what users might expect on macOS and Windows, but potentially slow down certificate validation depending on the underlying IO work done. This in turn can degrade application performance (example)
  • rustls-native-certs able to load the certificates from the system root, but does its own validation. This should result in consistent performance, but may result in surprising validation results (i.e. a certificate still being treated as valid when it has in fact been revoked, requiring a restart)

I'm not sure yet which option would be better.

@yorickpeterse
Copy link
Collaborator Author

Per rustls/rustls-native-certs#30, it seems that if we use rustls-native-certs then loading the certificates (which happens when creating a client config) could potentially take a long time.

yorickpeterse added a commit that referenced this issue Jul 19, 2024
This adds the module std.net.tls and refactors std.net.socket in various
places, such that we can provide support for TLS 1.2 and TLS 1.3.

The TLS stack is backed by Rustls (https://github.com/rustls/rustls). My
original plan was to write the stack in Inko, but I deemed this far too
time consuming and not beneficial for users (compared to using an
existing mature stack). I also experimented with OpenSSL, but using
OpenSSL is like walking through a minefield, and its API is a pain to
use (in part due to its use of global and thread-local state).

Rustls is compiled such that it uses the "ring" backend instead of
aws-lc. This is done because aws-lc requires additional dependencies on
FreeBSD, and increases compile times significantly (about 30 seconds or
so). While performance of TLS 1.3 is less ideal when using ring compared
to using aws-lc (rustls/rustls#1751), it
should still be good enough (and still be much faster compared to using
OpenSSL).

A downside of using Rustls is that the executable sizes increase by
about 6 MiB (or 2 MiB when stripping them), due to the extra code
introduced by Rustls and its dependencies. Sadly we can't avoid this
unless we use OpenSSL, which introduces far more pressing issues.

This fixes #329.

Changelog: added
@yorickpeterse
Copy link
Collaborator Author

I'm inclined to just stick with rustls-platform-verifier, as the (potential) performance implications only apply on macOS, and even then it's not clear how likely they are to happen.

What we could do is fork the project and modify the code that does the verification such that it's wrapped in a Process::blocking call. This way any delays introduced by it won't hog an entire OS thread. The challenge here is that we have to somehow inject the current process into that code, preferably without the use of thread-locals.

yorickpeterse added a commit that referenced this issue Jul 19, 2024
This adds the module std.net.tls and refactors std.net.socket in various
places, such that we can provide support for TLS 1.2 and TLS 1.3.

The TLS stack is backed by Rustls (https://github.com/rustls/rustls). My
original plan was to write the stack in Inko, but I deemed this far too
time consuming and not beneficial for users (compared to using an
existing mature stack). I also experimented with OpenSSL, but using
OpenSSL is like walking through a minefield, and its API is a pain to
use (in part due to its use of global and thread-local state).

Rustls is compiled such that it uses the "ring" backend instead of
aws-lc. This is done because aws-lc requires additional dependencies on
FreeBSD, and increases compile times significantly (about 30 seconds or
so). While performance of TLS 1.3 is less ideal when using ring compared
to using aws-lc (rustls/rustls#1751), it
should still be good enough (and still be much faster compared to using
OpenSSL).

A downside of using Rustls is that the executable sizes increase by
about 6 MiB (or 2 MiB when stripping them), due to the extra code
introduced by Rustls and its dependencies. Sadly we can't avoid this
unless we use OpenSSL, which introduces far more pressing issues.

For certificate validation we use a patched version of the
rustls-platform-verifier crate. The patched version strips the code we
don't need (mostly so we don't get tons of "this code is unused"
warnings and what not), and patches the macOS code to account for the
system verification process being (potentially) slow by using the
`Process::blocking` method.

This fixes #329.

Changelog: added
@yorickpeterse
Copy link
Collaborator Author

I ended up with vendoring and patching rustls-platform-verifier, such that it handles potentially blocking calls on macOS. It's not great that we have to vendor and patch things, but it seems to be the only working approach at this stage. Some additional details are found in this comment.

yorickpeterse added a commit that referenced this issue Jul 19, 2024
This adds the module std.net.tls and refactors std.net.socket in various
places, such that we can provide support for TLS 1.2 and TLS 1.3.

The TLS stack is backed by Rustls (https://github.com/rustls/rustls). My
original plan was to write the stack in Inko, but I deemed this far too
time consuming and not beneficial for users (compared to using an
existing mature stack). I also experimented with OpenSSL, but using
OpenSSL is like walking through a minefield, and its API is a pain to
use (in part due to its use of global and thread-local state).

Rustls is compiled such that it uses the "ring" backend instead of
aws-lc. This is done because aws-lc requires additional dependencies on
FreeBSD, and increases compile times significantly (about 30 seconds or
so). While performance of TLS 1.3 is less ideal when using ring compared
to using aws-lc (rustls/rustls#1751), it
should still be good enough (and still be much faster compared to using
OpenSSL).

A downside of using Rustls is that the executable sizes increase by
about 6 MiB (or 2 MiB when stripping them), due to the extra code
introduced by Rustls and its dependencies. Sadly we can't avoid this
unless we use OpenSSL, which introduces far more pressing issues.

For certificate validation we use a patched version of the
rustls-platform-verifier crate. The patched version strips the code we
don't need (mostly so we don't get tons of "this code is unused"
warnings and what not), and patches the macOS code to account for the
system verification process being (potentially) slow by using the
`Process::blocking` method.

This fixes #329.

Changelog: added
yorickpeterse added a commit that referenced this issue Jul 22, 2024
This adds the module std.net.tls and refactors std.net.socket in various
places, such that we can provide support for TLS 1.2 and TLS 1.3.

The TLS stack is backed by Rustls (https://github.com/rustls/rustls). My
original plan was to write the stack in Inko, but I deemed this far too
time consuming and not beneficial for users (compared to using an
existing mature stack). I also experimented with OpenSSL, but using
OpenSSL is like walking through a minefield, and its API is a pain to
use (in part due to its use of global and thread-local state).

Rustls is compiled such that it uses the "ring" backend instead of
aws-lc. This is done because aws-lc requires additional dependencies on
FreeBSD, and increases compile times significantly (about 30 seconds or
so). While performance of TLS 1.3 is less ideal when using ring compared
to using aws-lc (rustls/rustls#1751), it
should still be good enough (and still be much faster compared to using
OpenSSL).

A downside of using Rustls is that the executable sizes increase by
about 6 MiB (or 2 MiB when stripping them), due to the extra code
introduced by Rustls and its dependencies. Sadly we can't avoid this
unless we use OpenSSL, which introduces far more pressing issues.

For certificate validation we use a patched version of the
rustls-platform-verifier crate. The patched version strips the code we
don't need (mostly so we don't get tons of "this code is unused"
warnings and what not), and patches the macOS code to account for the
system verification process being (potentially) slow by using the
`Process::blocking` method.

This fixes #329.

Changelog: added
yorickpeterse added a commit that referenced this issue Jul 22, 2024
This adds the module std.net.tls and refactors std.net.socket in various
places, such that we can provide support for TLS 1.2 and TLS 1.3.

The TLS stack is backed by Rustls (https://github.com/rustls/rustls). My
original plan was to write the stack in Inko, but I deemed this far too
time consuming and not beneficial for users (compared to using an
existing mature stack). I also experimented with OpenSSL, but using
OpenSSL is like walking through a minefield, and its API is a pain to
use (in part due to its use of global and thread-local state).

Rustls is compiled such that it uses the "ring" backend instead of
aws-lc. This is done because aws-lc requires additional dependencies on
FreeBSD, and increases compile times significantly (about 30 seconds or
so). While performance of TLS 1.3 is less ideal when using ring compared
to using aws-lc (rustls/rustls#1751), it
should still be good enough (and still be much faster compared to using
OpenSSL).

A downside of using Rustls is that the executable sizes increase by
about 6 MiB (or 2 MiB when stripping them), due to the extra code
introduced by Rustls and its dependencies. Sadly we can't avoid this
unless we use OpenSSL, which introduces far more pressing issues.

For certificate validation we use a patched version of the
rustls-platform-verifier crate. The patched version strips the code we
don't need (mostly so we don't get tons of "this code is unused"
warnings and what not), and patches the macOS code to account for the
system verification process being (potentially) slow by using the
`Process::blocking` method.

This fixes #329.

Changelog: added
yorickpeterse added a commit that referenced this issue Jul 23, 2024
This adds the module std.net.tls and refactors std.net.socket in various
places, such that we can provide support for TLS 1.2 and TLS 1.3.

The TLS stack is backed by Rustls (https://github.com/rustls/rustls). My
original plan was to write the stack in Inko, but I deemed this far too
time consuming and not beneficial for users (compared to using an
existing mature stack). I also experimented with OpenSSL, but using
OpenSSL is like walking through a minefield, and its API is a pain to
use (in part due to its use of global and thread-local state).

Rustls is compiled such that it uses the "ring" backend instead of
aws-lc. This is done because aws-lc requires additional dependencies on
FreeBSD, and increases compile times significantly (about 30 seconds or
so). While performance of TLS 1.3 is less ideal when using ring compared
to using aws-lc (rustls/rustls#1751), it
should still be good enough (and still be much faster compared to using
OpenSSL).

A downside of using Rustls is that the executable sizes increase by
about 6 MiB (or 2 MiB when stripping them), due to the extra code
introduced by Rustls and its dependencies. Sadly we can't avoid this
unless we use OpenSSL, which introduces far more pressing issues.

For certificate validation we use a patched version of the
rustls-platform-verifier crate. The patched version strips the code we
don't need (mostly so we don't get tons of "this code is unused"
warnings and what not), and patches the macOS code to account for the
system verification process being (potentially) slow by using the
`Process::blocking` method.

This fixes #329.

Changelog: added
yorickpeterse added a commit that referenced this issue Jul 24, 2024
This adds the module std.net.tls and refactors std.net.socket in various
places, such that we can provide support for TLS 1.2 and TLS 1.3.

The TLS stack is backed by Rustls (https://github.com/rustls/rustls). My
original plan was to write the stack in Inko, but I deemed this far too
time consuming and not beneficial for users (compared to using an
existing mature stack). I also experimented with OpenSSL, but using
OpenSSL is like walking through a minefield, and its API is a pain to
use (in part due to its use of global and thread-local state).

Rustls is compiled such that it uses the "ring" backend instead of
aws-lc. This is done because aws-lc requires additional dependencies on
FreeBSD, and increases compile times significantly (about 30 seconds or
so). While performance of TLS 1.3 is less ideal when using ring compared
to using aws-lc (rustls/rustls#1751), it
should still be good enough (and still be much faster compared to using
OpenSSL).

A downside of using Rustls is that the executable sizes increase by
about 6 MiB (or 2 MiB when stripping them), due to the extra code
introduced by Rustls and its dependencies. Sadly we can't avoid this
unless we use OpenSSL, which introduces far more pressing issues.

For certificate validation we use a patched version of the
rustls-platform-verifier crate. The patched version strips the code we
don't need (mostly so we don't get tons of "this code is unused"
warnings and what not), and patches the macOS code to account for the
system verification process being (potentially) slow by using the
`Process::blocking` method.

This fixes #329.

Changelog: added
yorickpeterse added a commit that referenced this issue Jul 24, 2024
This adds the module std.net.tls and refactors std.net.socket in various
places, such that we can provide support for TLS 1.2 and TLS 1.3.

The TLS stack is backed by Rustls (https://github.com/rustls/rustls). My
original plan was to write the stack in Inko, but I deemed this far too
time consuming and not beneficial for users (compared to using an
existing mature stack). I also experimented with OpenSSL, but using
OpenSSL is like walking through a minefield, and its API is a pain to
use (in part due to its use of global and thread-local state).

Rustls is compiled such that it uses the "ring" backend instead of
aws-lc. This is done because aws-lc requires additional dependencies on
FreeBSD, and increases compile times significantly (about 30 seconds or
so). While performance of TLS 1.3 is less ideal when using ring compared
to using aws-lc (rustls/rustls#1751), it
should still be good enough (and still be much faster compared to using
OpenSSL).

A downside of using Rustls is that the executable sizes increase by
about 6 MiB (or 2 MiB when stripping them), due to the extra code
introduced by Rustls and its dependencies. Sadly we can't avoid this
unless we use OpenSSL, which introduces far more pressing issues.

For certificate validation we use a patched version of the
rustls-platform-verifier crate. The patched version strips the code we
don't need (mostly so we don't get tons of "this code is unused"
warnings and what not), and patches the macOS code to account for the
system verification process being (potentially) slow by using the
`Process::blocking` method.

This fixes #329.

Changelog: added
yorickpeterse added a commit that referenced this issue Jul 25, 2024
This adds the module std.net.tls and refactors std.net.socket in various
places, such that we can provide support for TLS 1.2 and TLS 1.3.

The TLS stack is backed by Rustls (https://github.com/rustls/rustls). My
original plan was to write the stack in Inko, but I deemed this far too
time consuming and not beneficial for users (compared to using an
existing mature stack). I also experimented with OpenSSL, but using
OpenSSL is like walking through a minefield, and its API is a pain to
use (in part due to its use of global and thread-local state).

Rustls is compiled such that it uses the "ring" backend instead of
aws-lc. This is done because aws-lc requires additional dependencies on
FreeBSD, and increases compile times significantly (about 30 seconds or
so). While performance of TLS 1.3 is less ideal when using ring compared
to using aws-lc (rustls/rustls#1751), it
should still be good enough (and still be much faster compared to using
OpenSSL).

A downside of using Rustls is that the executable sizes increase by
about 6 MiB (or 2 MiB when stripping them), due to the extra code
introduced by Rustls and its dependencies. Sadly we can't avoid this
unless we use OpenSSL, which introduces far more pressing issues.

For certificate validation we use a patched version of the
rustls-platform-verifier crate. The patched version strips the code we
don't need (mostly so we don't get tons of "this code is unused"
warnings and what not), and patches the macOS code to account for the
system verification process being (potentially) slow by using the
`Process::blocking` method.

This fixes #329.

Changelog: added
yorickpeterse added a commit that referenced this issue Jul 25, 2024
This adds the module std.net.tls and refactors std.net.socket in various
places, such that we can provide support for TLS 1.2 and TLS 1.3.

The TLS stack is backed by Rustls (https://github.com/rustls/rustls). My
original plan was to write the stack in Inko, but I deemed this far too
time consuming and not beneficial for users (compared to using an
existing mature stack). I also experimented with OpenSSL, but using
OpenSSL is like walking through a minefield, and its API is a pain to
use (in part due to its use of global and thread-local state).

Rustls is compiled such that it uses the "ring" backend instead of
aws-lc. This is done because aws-lc requires additional dependencies on
FreeBSD, and increases compile times significantly (about 30 seconds or
so). While performance of TLS 1.3 is less ideal when using ring compared
to using aws-lc (rustls/rustls#1751), it
should still be good enough (and still be much faster compared to using
OpenSSL).

A downside of using Rustls is that the executable sizes increase by
about 6 MiB (or 2 MiB when stripping them), due to the extra code
introduced by Rustls and its dependencies. Sadly we can't avoid this
unless we use OpenSSL, which introduces far more pressing issues.

For certificate validation we use a patched version of the
rustls-platform-verifier crate. The patched version strips the code we
don't need (mostly so we don't get tons of "this code is unused"
warnings and what not), and patches the macOS code to account for the
system verification process being (potentially) slow by using the
`Process::blocking` method.

This fixes #329.

Changelog: added
yorickpeterse added a commit that referenced this issue Jul 25, 2024
This adds the module std.net.tls and refactors std.net.socket in various
places, such that we can provide support for TLS 1.2 and TLS 1.3.

The TLS stack is backed by Rustls (https://github.com/rustls/rustls). My
original plan was to write the stack in Inko, but I deemed this far too
time consuming and not beneficial for users (compared to using an
existing mature stack). I also experimented with OpenSSL, but using
OpenSSL is like walking through a minefield, and its API is a pain to
use (in part due to its use of global and thread-local state).

Rustls is compiled such that it uses the "ring" backend instead of
aws-lc. This is done because aws-lc requires additional dependencies on
FreeBSD, and increases compile times significantly (about 30 seconds or
so). While performance of TLS 1.3 is less ideal when using ring compared
to using aws-lc (rustls/rustls#1751), it
should still be good enough (and still be much faster compared to using
OpenSSL).

A downside of using Rustls is that the executable sizes increase by
about 6 MiB (or 2 MiB when stripping them), due to the extra code
introduced by Rustls and its dependencies. Sadly we can't avoid this
unless we use OpenSSL, which introduces far more pressing issues.

For certificate validation we use a patched version of the
rustls-platform-verifier crate. The patched version strips the code we
don't need (mostly so we don't get tons of "this code is unused"
warnings and what not), and patches the macOS code to account for the
system verification process being (potentially) slow by using the
`Process::blocking` method.

This fixes #329.

Changelog: added
yorickpeterse added a commit that referenced this issue Jul 25, 2024
This adds the module std.net.tls and refactors std.net.socket in various
places, such that we can provide support for TLS 1.2 and TLS 1.3.

The TLS stack is backed by Rustls (https://github.com/rustls/rustls). My
original plan was to write the stack in Inko, but I deemed this far too
time consuming and not beneficial for users (compared to using an
existing mature stack). I also experimented with OpenSSL, but using
OpenSSL is like walking through a minefield, and its API is a pain to
use (in part due to its use of global and thread-local state).

Rustls is compiled such that it uses the "ring" backend instead of
aws-lc. This is done because aws-lc requires additional dependencies on
FreeBSD, and increases compile times significantly (about 30 seconds or
so). While performance of TLS 1.3 is less ideal when using ring compared
to using aws-lc (rustls/rustls#1751), it
should still be good enough (and still be much faster compared to using
OpenSSL).

A downside of using Rustls is that the executable sizes increase by
about 6 MiB (or 2 MiB when stripping them), due to the extra code
introduced by Rustls and its dependencies. Sadly we can't avoid this
unless we use OpenSSL, which introduces far more pressing issues.

For certificate validation we use a patched version of the
rustls-platform-verifier crate. The patched version strips the code we
don't need (mostly so we don't get tons of "this code is unused"
warnings and what not), and patches the macOS code to account for the
system verification process being (potentially) slow by using the
`Process::blocking` method.

This fixes #329.

Changelog: added
yorickpeterse added a commit that referenced this issue Jul 26, 2024
This adds the module std.net.tls and refactors std.net.socket in various
places, such that we can provide support for TLS 1.2 and TLS 1.3.

The TLS stack is backed by Rustls (https://github.com/rustls/rustls). My
original plan was to write the stack in Inko, but I deemed this far too
time consuming and not beneficial for users (compared to using an
existing mature stack). I also experimented with OpenSSL, but using
OpenSSL is like walking through a minefield, and its API is a pain to
use (in part due to its use of global and thread-local state).

Rustls is compiled such that it uses the "ring" backend instead of
aws-lc. This is done because aws-lc requires additional dependencies on
FreeBSD, and increases compile times significantly (about 30 seconds or
so). While performance of TLS 1.3 is less ideal when using ring compared
to using aws-lc (rustls/rustls#1751), it
should still be good enough (and still be much faster compared to using
OpenSSL).

A downside of using Rustls is that the executable sizes increase by
about 6 MiB (or 2 MiB when stripping them), due to the extra code
introduced by Rustls and its dependencies. Sadly we can't avoid this
unless we use OpenSSL, which introduces far more pressing issues.

For certificate validation we use a patched version of the
rustls-platform-verifier crate. The patched version strips the code we
don't need (mostly so we don't get tons of "this code is unused"
warnings and what not), and patches the macOS code to account for the
system verification process being (potentially) slow by using the
`Process::blocking` method.

This fixes #329.

Changelog: added
yorickpeterse added a commit that referenced this issue Jul 26, 2024
This adds the module std.net.tls and refactors std.net.socket in various
places, such that we can provide support for TLS 1.2 and TLS 1.3.

The TLS stack is backed by Rustls (https://github.com/rustls/rustls). My
original plan was to write the stack in Inko, but I deemed this far too
time consuming and not beneficial for users (compared to using an
existing mature stack). I also experimented with OpenSSL, but using
OpenSSL is like walking through a minefield, and its API is a pain to
use (in part due to its use of global and thread-local state).

Rustls is compiled such that it uses the "ring" backend instead of
aws-lc. This is done because aws-lc requires additional dependencies on
FreeBSD, and increases compile times significantly (about 30 seconds or
so). While performance of TLS 1.3 is less ideal when using ring compared
to using aws-lc (rustls/rustls#1751), it
should still be good enough (and still be much faster compared to using
OpenSSL).

A downside of using Rustls is that the executable sizes increase by
about 6 MiB (or 2 MiB when stripping them), due to the extra code
introduced by Rustls and its dependencies. Sadly we can't avoid this
unless we use OpenSSL, which introduces far more pressing issues.

For certificate validation we use a patched version of the
rustls-platform-verifier crate. The patched version strips the code we
don't need (mostly so we don't get tons of "this code is unused"
warnings and what not), and patches the macOS code to account for the
system verification process being (potentially) slow by using the
`Process::blocking` method.

This fixes #329.

Changelog: added
yorickpeterse added a commit that referenced this issue Jul 26, 2024
This adds the module std.net.tls and refactors std.net.socket in various
places, such that we can provide support for TLS 1.2 and TLS 1.3.

The TLS stack is backed by Rustls (https://github.com/rustls/rustls). My
original plan was to write the stack in Inko, but I deemed this far too
time consuming and not beneficial for users (compared to using an
existing mature stack). I also experimented with OpenSSL, but using
OpenSSL is like walking through a minefield, and its API is a pain to
use (in part due to its use of global and thread-local state).

Rustls is compiled such that it uses the "ring" backend instead of
aws-lc. This is done because aws-lc requires additional dependencies on
FreeBSD, and increases compile times significantly (about 30 seconds or
so). While performance of TLS 1.3 is less ideal when using ring compared
to using aws-lc (rustls/rustls#1751), it
should still be good enough (and still be much faster compared to using
OpenSSL).

A downside of using Rustls is that the executable sizes increase by
about 6 MiB (or 2 MiB when stripping them), due to the extra code
introduced by Rustls and its dependencies. Sadly we can't avoid this
unless we use OpenSSL, which introduces far more pressing issues.

For certificate validation we use a patched version of the
rustls-platform-verifier crate. The patched version strips the code we
don't need (mostly so we don't get tons of "this code is unused"
warnings and what not), and patches the macOS code to account for the
system verification process being (potentially) slow by using the
`Process::blocking` method.

This fixes #329.

Changelog: added
yorickpeterse added a commit that referenced this issue Jul 26, 2024
This adds the module std.net.tls and refactors std.net.socket in various
places, such that we can provide support for TLS 1.2 and TLS 1.3.

The TLS stack is backed by Rustls (https://github.com/rustls/rustls). My
original plan was to write the stack in Inko, but I deemed this far too
time consuming and not beneficial for users (compared to using an
existing mature stack). I also experimented with OpenSSL, but using
OpenSSL is like walking through a minefield, and its API is a pain to
use (in part due to its use of global and thread-local state).

Rustls is compiled such that it uses the "ring" backend instead of
aws-lc. This is done because aws-lc requires additional dependencies on
FreeBSD, and increases compile times significantly (about 30 seconds or
so). While performance of TLS 1.3 is less ideal when using ring compared
to using aws-lc (rustls/rustls#1751), it
should still be good enough (and still be much faster compared to using
OpenSSL).

A downside of using Rustls is that the executable sizes increase by
about 6 MiB (or 2 MiB when stripping them), due to the extra code
introduced by Rustls and its dependencies. Sadly we can't avoid this
unless we use OpenSSL, which introduces far more pressing issues.

For certificate validation we use a patched version of the
rustls-platform-verifier crate. The patched version strips the code we
don't need (mostly so we don't get tons of "this code is unused"
warnings and what not), and patches the macOS code to account for the
system verification process being (potentially) slow by using the
`Process::blocking` method.

This fixes #329.

Changelog: added
yorickpeterse added a commit that referenced this issue Jul 29, 2024
This adds the module std.net.tls and refactors std.net.socket in various
places, such that we can provide support for TLS 1.2 and TLS 1.3.

The TLS stack is backed by Rustls (https://github.com/rustls/rustls). My
original plan was to write the stack in Inko, but I deemed this far too
time consuming and not beneficial for users (compared to using an
existing mature stack). I also experimented with OpenSSL, but using
OpenSSL is like walking through a minefield, and its API is a pain to
use (in part due to its use of global and thread-local state).

Rustls is compiled such that it uses the "ring" backend instead of
aws-lc. This is done because aws-lc requires additional dependencies on
FreeBSD, and increases compile times significantly (about 30 seconds or
so). While performance of TLS 1.3 is less ideal when using ring compared
to using aws-lc (rustls/rustls#1751), it
should still be good enough (and still be much faster compared to using
OpenSSL).

A downside of using Rustls is that the executable sizes increase by
about 6 MiB (or 2 MiB when stripping them), due to the extra code
introduced by Rustls and its dependencies. Sadly we can't avoid this
unless we use OpenSSL, which introduces far more pressing issues.

For certificate validation we use a patched version of the
rustls-platform-verifier crate. The patched version strips the code we
don't need (mostly so we don't get tons of "this code is unused"
warnings and what not), and patches the macOS code to account for the
system verification process being (potentially) slow by using the
`Process::blocking` method.

This fixes #329.

Changelog: added
@github-project-automation github-project-automation bot moved this from In Progress to Done in NLnet tasks Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New things to add to Inko, such as a new standard library module std Changes related to the standard library
Projects
No open projects
Status: Done
Development

No branches or pull requests

1 participant