summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibTLS
AgeCommit message (Collapse)Author
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.
2022-03-20LibCrypto+LibTLS: Generalize the elliptic curve interfaceMichiel Visser
These changes generalize the interface with an elliptic curve implementation. This allows LibTLS to support elliptic curves generally without needing the specifics of elliptic curve implementations. This should allow for easier addition of other elliptic curves.
2022-03-09LibTLS: Add support for curve x448stelar7
2022-02-23LibTLS: Add signature verification for DHE and ECDHE key exchangeMichiel Visser
This will verify that the signature of the ephemeral key used in the DHE and ECDHE key exchanges is actually generated by the server. This verification is done using the first certificate provided by the server, however the validity of this certificate is not checked here. Instead this code expects the validity to be checked earlier by `TLSv12::handle_certificate`.
2022-02-23LibTLS: ECDHE switch from FeatureNotSupported to NotUnderstood errorMichiel Visser
NotUnderstood will generate a TLS alert with an InternalError instead of crashing the RequestServer.
2022-02-23LibTLS: Add OutOfMemory error that will send an InternalError alertMichiel Visser
2022-02-18LibTLS: Add Elliptic Curve Diffie-Hellman Ephemeral (ECDHE) supportMichiel Visser
This adds support for the Elliptic Curve Diffie-Hellman Ephemeral key exchange, using the X25519 elliptic curve. This means that the ECDHE_RSA_WITH_AES_128_GCM_SHA256 and ECDHE_RSA_WITH_AES_256_GCM_SHA384 cipher suites are now supported. Currently, only the X25519 elliptic curve is supported in combination with the uncompressed elliptic curve point format. However, since the X25519 is the recommended curve, basically every server supports this. Furthermore, the uncompressed point format is required by the TLS specification, which means any server with EC support will support the uncompressed format. Like the implementation of the normal Diffie-Hellman Ephemeral key exchange, this implementation does not currently validate the signature of the public key sent by the server.
2022-02-16LibCore+Everywhere: Return ErrorOr from ConfigFile factory methodsSam Atkins
I've attempted to handle the errors gracefully where it was clear how to do so, and simple, but a lot of this was just adding `release_value_but_fixme_should_propagate_errors()` in places.
2022-02-13LibTLS: Add SHA-384 as supported certificate signing algorithmJoaquim Monteiro
2022-02-09LibTLS+RequestServer: Add an option to dump TLS keys to a log fileAli Mohammad Pur
This file allows us to decrypt TLS messages in wireshark, which can help immensely in debugging network stuff :^)
2022-02-06LibTLS: Remove some unused/unimplemented declarationsAli Mohammad Pur
2022-02-06Userland: Convert TLS::TLSv12 to a Core::Stream::SocketAli Mohammad Pur
This commit converts TLS::TLSv12 to a Core::Stream object, and in the process allows TLS to now wrap other Core::Stream::Socket objects. As a large part of LibHTTP and LibGemini depend on LibTLS's interface, this also converts those to support Core::Stream, which leads to a simplification of LibHTTP (as there's no need to care about the underlying socket type anymore). Note that RequestServer now controls the TLS socket options, which is a better place anyway, as RS is the first receiver of the user-requested options (though this is currently not particularly useful).
2022-01-24Everywhere: Convert ByteBuffer factory methods from Optional -> ErrorOrSam Atkins
Apologies for the enormous commit, but I don't see a way to split this up nicely. In the vast majority of cases it's a simple change. A few extra places can use TRY instead of manual error checking though. :^)
2022-01-08LibTLS: Mark the socket as idle after a TLS-level disconnectionAli Mohammad Pur
This fixes a bunch of RequestServer spins.
2022-01-07Everywhere: Fix many spelling errorsmjz19910
2021-12-08LibTLS: Avoid implicitly copying ByteBufferBen Wiederhake
2021-11-11Everywhere: Pass AK::ReadonlyBytes by valueAndreas Kling
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-11-10AK: Make ByteBuffer::try_* functions return ErrorOr<void>Andreas Kling
Same as Vector, ByteBuffer now also signals allocation failure by returning an ENOMEM Error instead of a bool, allowing us to use the TRY() and MUST() patterns.
2021-10-10LibTLS: Remove useless ByteBuffer allocation in TLSv12::read_line()Ali Mohammad Pur
2021-10-06LibTLS: Add missing headers to CipherSuite.hBen Wiederhake
2021-10-03LibTLS: Split large application data packets into chunksAli Mohammad Pur
Each TLS record has a limited max size, we should respect that and split the packets. Fixes RecordOverflow errors when a packet larger than 18432 bytes is sent over.
2021-10-01Libraries: Fix typosNico Weber
2021-09-28LibTLS: Mark the connection as finished and disconnected on TLS errorAli Mohammad Pur
2021-09-21Libraries: Use AK::Variant default initialization where appropriateBen Wiederhake
2021-09-19LibTLS: Use a setter for on_tls_ready_to_write with some more smartsAli Mohammad Pur
The callback should be called as soon as the connection is established, and if we actually set the callback when it already is, we expect it to be called immediately.