Commit Graph

1103 Commits

Author SHA1 Message Date
Wyatt O'Day
7da636cad5 version_win32: Check build number and platform id
Prior to this change the build number was not checked during version
comparison, and the platform id was supposed to be checked but wasn't.

Checking the build number is required for enabling "evergreen"
Windows 10/11 features (like TLS 1.3).

Ref: https://github.com/curl/curl/pull/7784

Closes https://github.com/curl/curl/pull/7824
Closes https://github.com/curl/curl/pull/7867
2021-12-02 03:39:14 -05:00
x2018
34294a65b2
openssl: check the return value of BIO_new()
Closes #8078
2021-12-01 11:51:53 +01:00
Florian Van Heghe
8443f975c0
mbedTLS: add support for CURLOPT_CAINFO_BLOB
Closes #8071
2021-11-30 16:19:46 +01:00
Jacob Hoffman-Andrews
3f8fde366f
rustls: remove comment about checking handshaking
The comment is incorrect in two ways:
 - It says the check needs to be last, but the check is actually first.
 - is_handshaking actually starts out true.

Closes #8038
2021-11-20 22:57:13 +01:00
Marcel Raad
9b9485e7ac openssl: use non-deprecated API to read key parameters
With OpenSSL 3.0, the parameters are read directly from the `EVP_PKEY`
using `EVP_PKEY_get_bn_param`.

Closes https://github.com/curl/curl/pull/7893
2021-11-20 12:04:57 +01:00
Marcel Raad
9b923eaf3e openssl: reduce code duplication
`BN_print`'s `BIGNUM` parameter has been `const` since OpenSSL 0.9.4.

Closes https://github.com/curl/curl/pull/7893
2021-11-20 12:04:56 +01:00
Marcel Raad
6147dfab93 openssl: remove RSA_METHOD_FLAG_NO_CHECK handling if unavailable
The flag has been deprecated without replacement in OpenSSL 3.0.

Closes https://github.com/curl/curl/pull/7893
2021-11-20 12:04:56 +01:00
Marcel Raad
1e80f56d0b openssl: remove usage of deprecated SSL_get_peer_certificate
The function name was changed to `SSL_get1_peer_certificate` in OpenSSL
3.0.

Closes https://github.com/curl/curl/pull/7893
2021-11-20 12:04:56 +01:00
Jacob Hoffman-Andrews
00f4ed2aad
rustls: read of zero bytes might be okay
When we're reading out plaintext from rustls' internal buffers, we might
get a read of zero bytes (meaning a clean TCP close, including
close_notify). However, we shouldn't return immediately when that
happens, since we may have already copied out some plaintext bytes.
Break out of the loop when we get a read of zero bytes, and figure out
which path we're dealing with.

Acked-by: Kevin Burke

Closes #8003
2021-11-13 22:57:51 +01:00
Jacob Hoffman-Andrews
be8d77b146
rustls: remove incorrect EOF check
The update to rustls-ffi 0.8.0 changed handling of EOF and close_notify.
From the CHANGELOG:

> Handling of unclean close and the close_notify TLS alert. Mirroring
> upstream changes, a rustls_connection now tracks TCP closed state like
> so: rustls_connection_read_tls considers a 0-length read from its
> callback to mean "TCP stream was closed by peer."  If that happens
> before the peer sent close_notify, rustls_connection_read will return
> RUSTLS_RESULT_UNEXPECTED_EOF once the available plaintext bytes are
> exhausted. This is useful to protect against truncation attacks. Note:
> some TLS implementations don't send close_notify. If you are already
> getting length information from your protocol (e.g. Content-Length in
> HTTP) you may choose to ignore UNEXPECTED_EOF so long as the number of
> plaintext bytes was as expected.

That means we don't need to check for unclean EOF in `cr_recv()`,
because `process_new_packets()` will give us an error if appropriate.

Closes #8003
2021-11-13 22:57:20 +01:00
Daniel Stenberg
76d9e07c6b
vtls/rustls: adapt to the updated rustls_version proto
Closes #7956
2021-11-11 13:47:41 +01:00
Kevin Burke
1fef5922da
vtls/rustls: handle RUSTLS_RESULT_PLAINTEXT_EMPTY
Previously we'd return CURLE_READ_ERROR if we received this, instead
of triggering the error handling logic that's present in the next if
block down.

After this change, curl requests to https://go.googlesource.com using
HTTP/2 complete successfully.

Fixes #7949
Closes #7948
2021-11-11 13:47:34 +01:00
Kevin Burke
b7757c2b81
vtls/rustls: update to compile with rustls-ffi v0.8.0
Some method names, as well as the generated library name, were changed
in a recent refactoring.

Further, change the default configuration instructions to check for
Hyper in either "target/debug" or "target/release" - the latter
contains an optimized build configuration.

Fixes #7947
Closes #7948
2021-11-11 13:47:25 +01:00
Jay Satiro
90e74206b9 schannel: fix memory leak due to failed SSL connection
- Call schannel_shutdown if the SSL connection fails.

Prior to this change schannel_shutdown (which shuts down the SSL
connection as well as memory cleanup) was not called when the SSL
connection failed (eg due to failed handshake).

Co-authored-by: Gisle Vanem

Fixes https://github.com/curl/curl/issues/7877
Closes https://github.com/curl/curl/pull/7878
2021-11-02 15:34:04 -04:00
Daniel Stenberg
83393b1a36
openssl: if verifypeer is not requested, skip the CA loading
It was previously done mostly to show a match/non-match in the verbose
output even when verification was not asked for. This change skips the
loading of the CA certs unless verifypeer is set to save memory and CPU.

Closes #7892
2021-10-22 16:16:19 +02:00
Daniel Stenberg
54aa9c48b2
tls: remove newline from three infof() calls
Follow-up to e7416cf

Reported-by: billionai on github
Fixes #7879
Closes #7880
2021-10-19 23:03:57 +02:00
Daniel Stenberg
f3c215e18a
openssl: with OpenSSL 1.1.0+ a failed RAND_status means goaway
One reason we know it can fail is if a provider is used that doesn't do
a proper job or is wrongly configured.

Reported-by: Michael Baentsch
Fixes #7840
Closes #7856
2021-10-14 22:44:58 +02:00
Anthony Hu
d10a0af2f3
wolfssl: allow setting of groups/curves
In particular, the quantum safe KEM and hybrid curves if wolfSSL is
built to support them.

Closes #7728
2021-09-30 17:28:56 +02:00
Daniel Gustafsson
12246eddc5 lib: avoid fallthrough cases in switch statements
Commit b5a434f7f0 inhibits the warning
on implicit fallthrough cases, since the current coding of indicating
fallthrough with comments is falling out of fashion with new compilers.
This attempts to make the issue smaller by rewriting fallthroughs to no
longer fallthrough, via either breaking the cases or turning switch
statements into if statements.

  lib/content_encoding.c: the fallthrough codepath is simply copied
    into the case as it's a single line.
  lib/http_ntlm.c: the fallthrough case skips a state in the state-
    machine and fast-forwards to NTLMSTATE_LAST. Do this before the
    switch statement instead to set up the states that we actually
    want.
  lib/http_proxy.c: the fallthrough is just falling into exiting the
    switch statement which can be done easily enough in the case.
  lib/mime.c: switch statement rewritten as if statement.
  lib/pop3.c: the fallthrough case skips to the next state in the
    statemachine, do this explicitly instead.
  lib/urlapi.c: switch statement rewritten as if statement.
  lib/vssh/wolfssh.c: the fallthrough cases fast-forwards the state
    machine, do this by running another iteration of the switch
    statement instead.
  lib/vtls/gtls.c: switch statement rewritten as if statement.
  lib/vtls/nss.c: the fallthrough codepath is simply copied into the
    case as it's a single line. Also twiddle a comment to not be
    inside a non-brace if statement.

Closes: #7322
See-also: #7295
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
2021-09-29 10:00:52 +02:00
Michael Kaufmann
60738f398c vtls: Fix a memory leak if an SSL session cannot be added to the cache
On connection shutdown, a new TLS session ticket may arrive after the
SSL session cache has already been destructed. In this case, the new
SSL session cannot be added to the SSL session cache.

The callers of Curl_ssl_addsessionid() need to know whether the SSL
session has been added to the cache. If it has not been added, the
reference counter of the SSL session must not be incremented, or memory
used by the SSL session must be freed. This is now possible with the new
output parameter "added" of Curl_ssl_addsessionid().

Fixes #7683
Closes #7752
2021-09-24 13:23:42 +02:00
Joel Depooter
bb72392647 schannel: fix typo
Closes https://github.com/curl/curl/pull/7769
2021-09-24 01:33:11 -04:00
Daniel Stenberg
0cc8fc8825
rustls: add strerror.h include
Follow-up to 2f0bb864c1
2021-09-10 15:20:20 +02:00
Daniel Stenberg
2f0bb864c1
lib: don't use strerror()
We have and provide Curl_strerror() internally for a reason: strerror()
is not necessarily thread-safe so we should always try to avoid it.

Extended checksrc to warn for this, but feature the check disabled by
default and only enable it in lib/

Closes #7685
2021-09-09 07:53:42 +02:00
MAntoniak
37fb213a2e
mbedtls: avoid using a large buffer on the stack
Use dynamic memory allocation for the buffer used in checking "pinned
public key". The PUB_DER_MAX_BYTES parameter with default settings is
set to a value greater than 2kB.

Co-authored-by: Daniel Stenberg
Closes #7586
2021-09-06 10:02:08 +02:00
Gisle Vanem
3a6d30cfd3 openssl: annotate SSL3_MT_SUPPLEMENTAL_DATA
This adds support for the previously unhandled supplemental data which
in -v output was printed like:

    TLSv1.2 (IN), TLS header, Unknown (23):

These will now be printed with proper annotation:

    TLSv1.2 (OUT), TLS header, Supplemental data (23):

Closes #7652
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
2021-09-01 22:46:21 +02:00
Ehren Bendler
797bacf9c5
wolfssl: clean up wolfcrypt error queue
If wolfSSL is built in certain ways (OPENSSL_EXTRA or Debug), the error
queue gets added on to for each session and never freed. Fix it by
calling ERR_clear_error() like in vtls/openssl when needed. This func is
a no-op in wolfcrypt if the error queue is not enabled.

Closes #7594
2021-08-21 17:05:14 +02:00
Jay Satiro
7d76be33d4 schannel: Work around typo in classic mingw macro
- Define ALG_CLASS_DHASH (the typo from the include) to ALG_CLASS_HASH.

Prior to this change there was an incomplete fix to ignore the
CALG_TLS1PRF macro on those versions of MinGW where it uses the
ALG_CLASS_DHASH typoed macro.

Ref: 48cf45c
Ref: https://osdn.net/projects/mingw/ticket/38391
Ref: https://github.com/curl/curl/issues/2924

Closes https://github.com/curl/curl/pull/7580
2021-08-21 03:05:33 -04:00
Daniel Stenberg
0da1356060
openssl: when creating a new context, there cannot be an old one
Remove the previous handling that would call SSL_CTX_free(), and instead
add an assert that halts a debug build if there ever is a context
already set at this point.

Closes #7585
2021-08-18 14:11:45 +02:00
Sergey Markelov
1828f6ae2e
sectransp: support CURLINFO_CERTINFO
Fixes #4130
Closes #7372
2021-08-17 08:40:44 +02:00
Daniel Stenberg
8c9722bb1c
misc: update incorrect copyright year ranges
Closes #7577
2021-08-16 11:21:47 +02:00
MAntoniak
fd84db600d
build: fix compiler warnings
For when CURL_DISABLE_VERBOSE_STRINGS and DEBUGBUILD flags are both
active.

- socks.c : warning C4100: 'lineno': unreferenced formal parameter
  (co-authored by Daniel Stenberg)

- mbedtls.c: warning C4189: 'port': local variable is initialized but
  not referenced

- schannel.c: warning C4189: 'hostname': local variable is initialized
  but not referenced

Cloes #7528
2021-08-14 23:19:24 +02:00
Ikko Ashimine
f67883e55a
vtls: fix typo in schannel_verify.c
occurence -> occurrence

Closes #7566
2021-08-13 17:39:59 +02:00
Benau
3f126138be
mbedTLS: initial 3.0.0 support
Closes #7428
2021-08-09 10:25:17 +02:00
modbw
65c1b8ee17
mbedtls_threadlock: fix unused variable warning
Closes #7393
2021-08-08 18:37:56 +02:00
Aleksandr Krotov
beb1b1cb03
bearssl: support CURLOPT_CAINFO_BLOB
Closes #7468
2021-07-28 23:04:53 +02:00
Josh Soref
e8cd39345e openssl: fix grammar
Closes https://github.com/curl/curl/pull/7480
2021-07-25 01:42:39 -04:00
Daniel Stenberg
5ea3145850
vtls: fix connection reuse checks for issuer cert and case sensitivity
CVE-2021-22924

Reported-by: Harry Sintonen
Bug: https://curl.se/docs/CVE-2021-22924.html
2021-07-20 09:36:06 +02:00
Daniel Stenberg
fd9b40bf8d
sectransp: check for client certs by name first, then file
CVE-2021-22926

Bug: https://curl.se/docs/CVE-2021-22926.html

Assisted-by: Daniel Gustafsson
Reported-by: Harry Sintonen
2021-07-20 09:36:06 +02:00
Gisle Vanem
c6fd7cbf10 [SChannel] Use '_tcsncmp()' instead
Revert previous change for PellesC. 

Instead replace all use of `_tcsnccmp()` with `_tcsncmp()`.
2021-07-16 07:30:35 +02:00
Gisle Vanem
3cd9a23e80 [PellesC] missing '_tcsnccmp'
PellesC compiler does not have this macro in it's `<tchar.h>`
2021-07-16 07:30:35 +02:00
Daniel Stenberg
e7416cfd2b
infof: remove newline from format strings, always append it
- the data needs to be "line-based" anyway since it's also passed to the
  debug callback/application

- it makes infof() work like failf() and consistency is good

- there's an assert that triggers on newlines in the format string

- Also removes a few instances of "..."

- Removes the code that would append "..." to the end of the data *iff*
  it was truncated in infof()

Closes #7357
2021-07-07 22:54:01 +02:00
Daniel Stenberg
1e488d38c9
wolfssl: failing to set a session id is not reason to error out
... as it is *probably* just timed out.

Reported-by: Francisco Munoz

Closes #7358
2021-07-07 10:19:28 +02:00
Daniel Stenberg
1ff1d9e179
lib: more %u for port and int for %*s fixes
Detected by Coverity

Closes #7329
2021-07-01 09:12:58 +02:00
Daniel Stenberg
78fc6522c2
lib: fix type of len passed to *printf's %*s
... it needs to be 'int'. Detected by Coverity CID 1486611 (etc)

Closes #7326
2021-06-30 23:53:58 +02:00
Daniel Stenberg
63c7668182
version: turn version number functions into returning void
... as we never use the return codes from them.

Reviewed-by: Daniel Gustafsson
Closes #7319
2021-06-30 23:23:34 +02:00
Daniel Stenberg
97fa671a73
vtls: use free() not curl_free()
curl_free() is provided for users of the API to free returned data,
there's no need to use it internally.

Closes #7318
2021-06-30 13:50:18 +02:00
Daniel Stenberg
4aed7a1923
openssl: avoid static variable for seed flag
Avoid the race condition risk by instead storing the "seeded" flag in
the multi handle. Modern OpenSSL versions handle the seeding itself so
doing the seeding once per multi-handle instead of once per process is
less of an issue.

Reported-by: Gerrit Renker
Fixes #7296
Closes #7306
2021-06-29 14:18:15 +02:00
Jay Satiro
b31d9ccfc2 vtls: fix warning due to function prototype mismatch
b09c8ee changed the function prototype. Caught by Visual Studio.
2021-06-21 01:59:05 -04:00
Daniel Stenberg
a6da296867
vtls: only store TIMER_APPCONNECT for non-proxy connect
Introducing a 'isproxy' argument to the connect function so that it
knows wether to store the time stamp or not.

Reported-by: Yongkang Huang
Fixes #7274
Closes #7274
2021-06-19 23:02:16 +02:00
Daniel Stenberg
bfa0309175
gnutls: set the preferred TLS versions in correct order
Regression since 781864bedb (curl 7.77.0)

Reported-by: civodul on github
Assisted-by: Nikos Mavrogiannopoulos
Fixes #7277
Closes #7278
2021-06-18 23:22:21 +02:00