summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibTLS
AgeCommit message (Collapse)Author
2023-04-03LibTLS: Refactor CA loading into central functionFabian Dellwing
2023-04-03AK+Everywhere: Change AK::fill_with_random to accept a Bytes objectTimothy Flynn
Rather than the very C-like API we currently have, accepting a void* and a length, let's take a Bytes object instead. In almost all existing cases, the compiler figures out the length.
2023-03-27LibTLS: Check if certificate is self signed before importing it as CAFabian Dellwing
2023-03-27LibTLS: Add self signage information to our parsed certificatesFabian Dellwing
2023-03-16LibTLS+Base: Rework default system certificate parserFabian Dellwing
Change the default system certificate parser from our arbitrary INI format to well-known PEM format.
2023-03-16Meta: Download cacert.pem at build timeFabian Dellwing
2023-03-13AK: Rename Stream::write_entire_buffer to Stream::write_until_depletedTim Schumacher
No functional changes.
2023-03-13AK: Rename Stream::{read,write} to Stream::{read_some,write_some}Tim Schumacher
Similar to POSIX read, the basic read and write functions of AK::Stream do not have a lower limit of how much data they read or write (apart from "none at all"). Rename the functions to "read some [data]" and "write some [data]" (with "data" being omitted, since everything here is reading and writing data) to make them sufficiently distinct from the functions that ensure to use the entire buffer (which should be the go-to function for most usages). No functional changes, just a lot of new FIXMEs.
2023-02-13LibCore: Remove `Stream.h`Tim Schumacher
2023-02-13LibCore: Move Stream-based file into the `Core` namespaceTim Schumacher
2023-02-13LibCore: Move Stream-based sockets into the `Core` namespaceTim Schumacher
2023-02-13LibCore: Rename `File` to `DeprecatedFile`Tim Schumacher
As usual, this removes many unused includes and moves used includes further down the chain.
2023-02-08LibTLS: Use `AK::Stream` for serializing TLS packetsTim Schumacher
We are working with a MemoryStream, so our stream operations shouldn't ever fail as long as we stay in-bounds, so `MUST` is fine.
2023-02-08LibCrypto: Use `ErrorOr` error handling for parsing DERTim Schumacher
This replaces a mixture of `Result`, `Optional`, and a custom error enum with our usual `ErrorOr`-based error handling.
2023-01-29AK: Deprecate the old `AK::Stream`Tim Schumacher
This also removes a few cases where the respective header wasn't actually required to be included.
2023-01-27AK: Remove StringBuilder::build() in favor of to_deprecated_string()Linus Groh
Having an alias function that only wraps another one is silly, and keeping the more obvious name should flush out more uses of deprecated strings. No behavior change.
2023-01-27LibTLS: Remove declarations for non-existent methodsSam Atkins
2023-01-15LibCrypto+Everywhere: Rename *BigInteger::to_base to to_base_deprecatedTimothy Flynn
2023-01-12LibCore+Userland: Make Core::Timer::create_single_shot() return ErrorOrSam Atkins
clang-format sure has some interesting opinions about where to put a method call that comes after a lambda. :thonk:
2022-12-12LibCore: Propagate errors from `Stream::*_entire_buffer`Tim Schumacher
2022-12-12LibCore: Rename `Stream::*_or_error` to `*_entire_buffer`Tim Schumacher
All of our functions are `_or_error` (or are about to be), and maybe making it less reminiscient of AK::Stream will make people use it more.
2022-12-12LibCore: Remove `Stream::is_{readable,writable}`Tim Schumacher
Next to functions like `is_eof` these were really confusing to use, and the `read`/`write` functions should fail anyways if a stream is not readable/writable.
2022-12-06Everywhere: Rename to_{string => deprecated_string}() where applicableLinus Groh
This will make it easier to support both string types at the same time while we convert code, and tracking down remaining uses. One big exception is Value::to_string() in LibJS, where the name is dictated by the ToString AO.
2022-12-06AK+Everywhere: Rename String to DeprecatedStringLinus Groh
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
2022-12-03Everywhere: Run clang-formatLinus Groh
2022-11-03Everywhere: Clean up "the the" comment typosNico Weber
2022-11-01Everywhere: Mark dependencies of most targets as PRIVATETim Schumacher
Otherwise, we end up propagating those dependencies into targets that link against that library, which creates unnecessary link-time dependencies. Also included are changes to readd now missing dependencies to tools that actually need them.
2022-10-15headless-browser: Add ca-certs-path optionsleeight
2022-09-16Everywhere: Remove a bunch of dead write-only variablesTim Schumacher
LLVM 15 now warns (and thus errors) about this, and there is really no point in keeping them.
2022-07-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
2022-07-12Everywhere: Split Error::from_string_literal and Error::from_string_viewsin-ack
Error::from_string_literal now takes direct char const*s, while Error::from_string_view does what Error::from_string_literal used to do: taking StringViews. This change will remove the need to insert `sv` after error strings when returning string literal errors once StringView(char const*) is removed. No functional changes.
2022-06-13AK/ByteBuffer+Everywhere: Handle errors in ByteBuffer::slice()Matthias Zimmerman
2022-04-17LibTLS: Cleanup of verify_chain and verify_certificate_pairMichiel Visser
2022-04-17LibCrypto: Certificate parse IP address SANMichiel Visser
Subject alternative name entries containing IP addresses will now be parsed and added to the list of SANs. This should allow for certificate verification when accessing IP addresses directly.
2022-04-17LibTLS: Add option to allow self-signed certificatesMichiel Visser
With this option enabled self-signed certificates will be accepted, eventhough they cannot be verified.
2022-04-17LibCrypto+LibTLS: Implement Key Usage and Basic Constraints extensionsMichiel Visser
Root and intermediate CA certificates should have these extensions set to indicate that they are allowed to sign other certificates. The values reported in these extensions is now also checked by `verify_chain` to make sure no non-CA certificates are used to sign another certificate. The certificate parser now also aborts when a critical extension is detected which is unsupported, as is required by the specification.
2022-04-17LibCrypto: Implement custom BitStringView for ASN.1 decoderMichiel Visser
The ASN.1 decoder was originally using AK::BitmapView for decoded BitStrings, however the specification requires that the bits are stored in a byte from the most significant to the least significant. Storing three bits '110' would result in a byte '1100 0000', i.e. 0xC0. However, AK::BitmapView expects the bits to be stored at the bottom like '0000 0110', i.e. 0x06. For the current uses the data was always a multiple of eight bits, resulting in complete bytes, which could directly be interpreted correctly. For the implementation of the key usage extension of certificates the correct implementation of the BitString is required.
2022-04-17LibTLS: Correct matching hostname with certificate subjectMichiel Visser
The wildcard specified in a certificates subject can only match a single level of subdomains. Originally, this function could match multiple levels of subdomains with a single "*.". As an example, https://wrong.host.badssl.com/ should fail to load, as the certificate provided by the server only specifies "*.badssl.com". However this was correctly matching anyway. With this change this page now correctly fails to load.
2022-04-17LibTLS: Add references to RFC5246 for the verify procedureMichiel Visser
2022-04-17LibTLS: Simplify the way `verify_chain` is calledMichiel Visser
The `build_rsa_pre_master_secret` function originally called `verify_chain_and_get_matching_certificate`, which verified the chain and returned a certificate matching the specified hostname. Since the first certificate in the chain should always be the one matching with the hostname, we can simply use that one instead. This means we can completely remove this method and just use `verify_chain`. To make sure the hostname is still verified, `verify_chain` now also checks that the first certificate in the chain matches the specified hostname. If the hostname is empty, we currently fail the verification, however this basically never happen, as the server name indication extension is always used.
2022-04-17LibTLS: Verify the certificate chain sent by the serverMichiel Visser
With this change the certificate chain sent by the server will actually be verified, instead of just checking the names of the certificates. To determine if a certificate is signed by a root certificate, the list of root certificates is now a HashMap mapping from the unique identifier string to the certificate. This allows us to take the issuer of a certificate and easily check if it is a root certificate. If a certificate is not signed by a root certificate, we will check that it is signed by the next certificate in the chain. This also removes the ad-hoc checking of certificate validity from multiple places, and moves all checking to the verify_chain.
2022-04-17LibTLS: Parse Certificate signature algorithm and valueMichiel Visser
This part of the certificate was originally just skipped, however it will be needed to check the validity of the certificate.
2022-04-17Base+LibTLS: Update CA Certificates list with actual certificatesMichiel Visser
The CA certificates list now contains the actual certificate data for approximatly a hundred certificate authorities. These certificates were generated from https://mkcert.org, which uses the Mozilla CA certificate list. This also updates the code for reading the CA certificates.
2022-04-17LibTLS: Add certificate chain validation to DHE and ECDHE key exchangeMichiel Visser
The RSA key exchange was the only one actually verifying the validity of the certificate chain supplied by the server. Now the DHE and ECDHE key exchanges also check the certificate chain.
2022-04-16LibCore+Everywhere: Make Core::Stream::read() return BytesSam Atkins
A mistake I've repeatedly made is along these lines: ```c++ auto nread = TRY(source_file->read(buffer)); TRY(destination_file->write(buffer)); ``` It's a little clunky to have to create a Bytes or StringView from the buffer's data pointer and the nread, and easy to forget and just use the buffer. So, this patch changes the read() function to return a Bytes of the data that were just read. The other read_foo() methods will be modified in the same way in subsequent commits. Fixes #13687
2022-04-15LibDNS: Remove the 'DNS' prefix from the various type and class namesTom
Since all types and class names live in the DNS namespace, we don't need to spell it out twice each time.
2022-04-09LibTLS: Mark the underlying stream as nonblockAli Mohammad Pur
LibTLS does not want to be blocked.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-20LibHTTP+LibTLS: Better HTTPS Socket EOF detectionFlorent Castelli
When the server doesn't signal the Content-Length or use a chunked mode, it may just terminate the connection after sending the data. The TLS sockets would then get stuck in a state with no data to read and not reach the disconnected state, making some requests hang. We know double check the EOF status of HTTP jobs after reading the payload to resolve requests properly and also mark the TLS sockets as EOF after processing all the data and the underlying TCP socket reaches EOF. Fixes #12866.
2022-03-20LibCrypto+LibTLS: Add SECP256r1 support to LibTLSMichiel Visser
Add the required methods to SECP256r1 to conform to the EllipticCurve virtual base class. Using this updated version of SECP256r1, support in LibTLS is implemented.