-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
Comments
marked this issue as related to #283 |
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. |
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. |
https://github.com/fres621/inko-tls/ might prove useful as a reference. |
Per the source code of rustls' |
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. |
This fixes #329. Changelog: added
This fixes #329. Changelog: added
This fixes #329. Changelog: added
This fixes #329. Changelog: added
This fixes #329. Changelog: added
This fixes #329. Changelog: added
This fixes #329. Changelog: added
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
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
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
Regarding splitting libraries, I think that might actually make things worse: Rust doesn't have a stable ABI, so the separate TLS crate producing |
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
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. |
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):
Based on this (and assuming this pattern holds for other languages), it seems a little inconsistent as to what approach is used. |
The choices come down to the following:
I'm not sure yet which option would be better. |
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. |
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
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 |
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
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. |
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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:
resulting API may be annoying to use
to a minimum
support anyway, such as cryptographic functions. Instead of exposing all that
through the VM, I want to write as much in Inko as possible
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:
std.base64
, needed to parse PEM filesstd.crypto.pem
for parsing PEM filesstd.crypto.x509
for defining basic certificate and private key types. For the time being these are just wrappers around aByteArray
std.net.tls
such thatClientConfig
andServerConfig
acceptCertificate
andPrivateKey
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 rustlsThe text was updated successfully, but these errors were encountered: