Commit Graph

95 Commits

Author SHA1 Message Date
Pierre Ossman
5ce283806c Restore leniance in certificate key usage violations
It was removed in 256d8e2 because the purpose was unclear. It turns
out that the automatically generated self signed certificates will
have Key Encipherment and Data Encipherment set as key usage, but
the required ones are Digital Signature and Key Encipherment. A
proper certificate generally doesn't have this issue, but connecting
to stand alone machines without a proper certificate is common.

Unfortunately the %COMPAT flag is the only thing that makes GnuTLS
tolerate this bug, but that flag also allows a lot of other protocol
violations.
2019-09-20 09:00:04 +02:00
Pierre Ossman
256d8e2b3c Respect TLS version argument
The code handling it was lost in the switch from OpenSSL to GnuTLS.
Restore the functionality in the new code.
2019-09-16 09:24:49 +02:00
Pierre Ossman
6028c999ba Allow TLS to continue without system database
It will mean manual confirmation for users, but that is probably
better than outright refusal.
2019-06-04 16:53:13 +02:00
Pierre Ossman
e7bc37918c Don't use assert() for error handling
It is excessively harsh in its output, and it can be completely
compiled out which will give an incorrect behaviour.
2019-06-04 16:51:30 +02:00
Pierre Ossman
25b8412333 Avoid poking around in STREAM internals
It's easy to make mistakes this way, and bypassed the normal bounds
checking. So make sure we always use macros or functions.
2019-05-06 14:33:38 +02:00
Pierre Ossman
489c43f382 Return STREAM objects from data generating functions
Use a consistent style of returning a new STREAM object from functions
that output data, rather than requiring an existing structure to be
passed in. This generally makes the memory management more straight
forward and allows us to do more proper bounds checking of everything.

This also adds some new STREAM macros to make it easier to manage
them without poking around in the internal structure.
2019-05-06 14:33:11 +02:00
Pierre Ossman
c6d8b933c8 Avoid preallocated streams in tcp.c
We don't know when the caller might be done with a stream, so we
can end up with code overwriting things in a stream that is in use
elsewhere.

Solve the issue by returning a new stream each time and leave it
up to the callers to free it.
2019-05-06 14:33:05 +02:00
Pierre Ossman
df94870c91 Remove unused variables and functions 2019-04-12 14:37:24 +02:00
Alexander Zakharov
85f99edd65 Update copyrights 2019-02-01 11:21:32 +03:00
Henrik Andersson
e021920813 This commit have multiple fixes:
- Break out code from tcp.c into utils.c for handling
   of adding certificate exceptions

 - Add clarifications why a certificate is untrusted

 - Add simplified certificate view with fingerprints for
   review.
2019-01-30 16:12:15 +01:00
Henrik Andersson
b9a50db894 Print full cert for review 2019-01-29 10:38:14 +01:00
Henrik Andersson
f8581c40b0 Remove unused code block and add generic error logging 2019-01-29 10:38:14 +01:00
Henrik Andersson
eacecac99c Set base requirement of GnuTLS to >= 3.2.0 2019-01-29 10:38:14 +01:00
Henrik Andersson
6577cc57e9 Do not use DN as key for certificate cache as it is insecure 2019-01-29 10:38:14 +01:00
Henrik Andersson
3ab19d543c Revert "Added implementation of a gnutls pubkey store (tdb)"
This reverts commit f493395fc7e36e504c27cab8ad973042c55f0767.
2019-01-29 10:38:14 +01:00
Henrik Andersson
95fac5e1f6 Revert "Use base64 encode/decode routines from nettle instead of gnutls"
This reverts commit 252bc346e2379475f8547d4a458743bed067448d.
2019-01-29 10:38:14 +01:00
Henrik Andersson
18287bdacf Add certificate verification against system trust store
Verify the certificate from the peer against the system’s default
trusted CAs. If certificate fails the verification a fallback to
use the certificate cache is used.

The certificate cache is used to give the user the option to add
exceptions for invalid certificates. For example; self-signed
certificates etc.
2019-01-29 10:38:14 +01:00
Henrik Andersson
2a955dbf84 Never silently add a certificate to cache
A user always needs to approve to add an exception for
a invalid certificate.
2019-01-29 10:38:14 +01:00
Henrik Andersson
a61bb39dec Fix compiling warnings 2019-01-29 10:38:14 +01:00
Henrik Andersson
307ca2eb03 Use base64 encode/decode routines from nettle instead of gnutls
This relaxes the version requirement for gnutls
2019-01-29 10:38:14 +01:00
Henrik Andersson
4781868e33 Added implementation of a gnutls pubkey store (tdb)
This fixes the problem with the default gnutls implementaion
that keys could not be updated eg. overwritten.
2019-01-29 10:38:14 +01:00
Henrik Andersson
11ca5446d9 Make certificate mismatch handling use util_dialog_choice() 2019-01-29 10:38:14 +01:00
Alexander Zakharov
d7d55cf3f7 PoC: Check server's certificate 2019-01-29 10:38:13 +01:00
Alexander Zakharov
23e22e3834 Temporary fix for gnutls_handshake() failure 2019-01-29 10:38:13 +01:00
Alexander Zakharov
166d1bc14d Replace OpenSSL with GnuTLS for all network communications 2019-01-29 10:38:13 +01:00
Henrik Andersson
c16b74a974 Run indent-all.sh script on source 2018-10-29 15:53:57 +01:00
gpatel-fr
8fcb535eba fix comments about TLS version 2018-10-22 21:03:57 +02:00
gpatel-fr
305b06d7fd Add TLS 1.1 and 1.2 support 2018-10-18 17:35:02 +02:00
Pierre Ossman
74b2129e09 Free socket buffers on disconnect
Otherwise we would leak the memory on every reconnect (and exit).
2018-07-02 13:40:46 +02:00
Karl Mikaelsson
081eac429c Save and re-use resolved address for given hostname
If tcp_connect is called with the same server name, don't look up the
address again. This avoids connecting to other servers when using a
round-robin RDS farm name, as recommended by Microsoft.

This introduces a backwards-incompatible change. If rdesktop was
reconnecting because the user was moving between networks and the
server is no longer reachable on the same address, the user must
re-start rdesktop to reach their server.
2018-03-28 13:35:10 +02:00
Karl Mikaelsson
5c48d5d788
Revert "Reconnect-related fixes" 2018-03-23 15:49:11 +01:00
Karl Mikaelsson
d6c99bf599 Save and re-use resolved address for given hostname
If tcp_connect is called with the same server name, don't look up the
address again. This avoids connecting to other servers when using a
round-robin RDS farm name, as recommended by Microsoft.

This introduces a backwards-incompatible change. If rdesktop was
reconnecting because the user was moving between networks and the
server is no longer reachable on the same address, the user must
re-start rdesktop to reach their server.
2018-03-22 15:36:36 +01:00
Cendio
ab50ea31cf Implement dynamic session resize
This adds support for resizing the RDP session dynamically based on
the window size. Some complicated logic has been added to avoid
sending excessive amounts of resize requests to the RDP server.

When supported, this resize mechanism should use the RDPEDISP way of
signalling the server to initiate a Deactivate/Activate sequence, but
rdesktop will fall back on Disconnect/Reconnect if RDPEDISP is not
supported by the server.

ui_select has been refactored and most functionality has been broken
out into three new functions, simplifying ui_select into a loop.

Signed-off-by: Henrik Andersson <hean01@cendio.com>
Signed-off-by: Karl Mikaelsson <derfian@cendio.se>
Signed-off-by: Thomas Nilefalk <thoni56@cendio.se>
2017-12-07 11:15:03 +01:00
Henrik Andersson
fc6ce03875 Make use of shared stream api
Remove own componized realloc and reset code to
shared stream api implementation.
2017-09-28 19:15:00 +02:00
Henrik Andersson
908ad64d84 Add additional logging for SSL errors
This was added to provide more information when things fails
as in  issue #118.
2017-05-12 13:15:45 +02:00
Henrik Andersson
87d8d123b8 Rework the logging system
This commit will add a logging system to solve the problem that
one actually need to recompile rdesktop from source to enable
different debug logging.

- Same logging api  for all kind of logging and messages to
   end user.

- Adding -v for verbose output when running rdesktop.

- All messages are logged into a subject and with a type, eg:

     logger(Keyboard, Notice, "Autos-electing %s based on locale.", locale);

- Debug logging is enabled trough a environment variable RDEKSTOP_DEBUG,
  which specifies subjects of interest, comma separated. There is a special
  subject named All which includes all subject for debug loggin. There is also
  a simple logic opeartor '!' = NOT which can be used in combination like:

    RDESKTOP_DEBUG=All,!Graphics,!Sound

  Which would give debug log output for All subject except Graphics and Sound.
2017-01-26 14:19:40 +01:00
Henrik Andersson
a90ea17abb Test if SSL_OP_NO_COMPRESSION is defined before use.
OpenSSL < 0.9.9 does not support this option, see upstream
commit 566dda07ba16f9d3b9774fd5c8d526d7cc93f179 for reference.



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1734 423420c4-83ab-492f-b58f-81f9feb106b5
2013-08-29 14:27:25 +00:00
Henrik Andersson
be5ae57fe0 Return a NULL value as expected.
Partly fix for bug #366



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1728 423420c4-83ab-492f-b58f-81f9feb106b5
2013-08-10 16:16:55 +00:00
Henrik Andersson
cab6380beb Do not do SSL_Shutdown if we have triggered a network error,
this will result in segfault in ssl.



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1722 423420c4-83ab-492f-b58f-81f9feb106b5
2013-06-27 10:43:34 +00:00
Henrik Andersson
adbb6cf0fc Run indent-all script.
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1721 423420c4-83ab-492f-b58f-81f9feb106b5
2013-06-20 12:57:00 +00:00
Henrik Andersson
e6b10f6bcb Added tcp_ui_run() to prevent ui_select() push data on transport
which corrupts the stream and prevents a SSL reconnect to work.



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1720 423420c4-83ab-492f-b58f-81f9feb106b5
2013-06-20 12:51:27 +00:00
Henrik Andersson
dc3be1486d Bring back reset of g_ssl on reset_state()
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1719 423420c4-83ab-492f-b58f-81f9feb106b5
2013-06-20 11:10:24 +00:00
Henrik Andersson
8200b5bbd4 Move g_ssl cleanup from reset_state() and only setup one ssl context per process.
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1718 423420c4-83ab-492f-b58f-81f9feb106b5
2013-06-20 10:50:39 +00:00
Henrik Andersson
8ba120fdbd SSL library initialization is not reentrant, lets do it once.
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1717 423420c4-83ab-492f-b58f-81f9feb106b5
2013-06-20 09:36:11 +00:00
Henrik Andersson
ae7c48a1c0 Set g_sock at correct point and remove from reset_state()
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1716 423420c4-83ab-492f-b58f-81f9feb106b5
2013-06-20 09:29:21 +00:00
Henrik Andersson
cd7a7342cb Silence some error spamming when rdesktop is in reconnect loop.
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1713 423420c4-83ab-492f-b58f-81f9feb106b5
2013-06-14 12:54:38 +00:00
Henrik Andersson
7d2f65002a Make sure we don't spam log with failed send() messages if we
already have detected a network failure.



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1711 423420c4-83ab-492f-b58f-81f9feb106b5
2013-06-13 11:01:55 +00:00
Henrik Andersson
eced6ca821 Reconnect upon network failure, retry as long the autoreconnect
cookie is valid.



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1707 423420c4-83ab-492f-b58f-81f9feb106b5
2013-04-12 06:46:07 +00:00
Henrik Andersson
9f174ea864 Added check if socket is connected to prevent sending disconnect
sequence to a closed socket.

git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1681 423420c4-83ab-492f-b58f-81f9feb106b5
2012-11-22 13:38:35 +00:00
Henrik Andersson
6d437f8116 Change the SSL context option to specific onse instead of using all
which introduces some problems.
Added some graceful handling of peer SSL shutdown for better error
reporting.

git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1675 423420c4-83ab-492f-b58f-81f9feb106b5
2012-11-15 11:20:37 +00:00