Commit Graph

6367 Commits

Author SHA1 Message Date
Emmanuel Hocdet
df701a2adb MINOR: ssl: support ssl-min-ver and ssl-max-ver with crt-list
SSL/TLS version can be changed per certificat if and only if openssl lib support
earlier callback on handshake and, of course, is implemented in haproxy. It's ok
for BoringSSL. For Openssl, version 1.1.1 have such callback and could support it.
2017-06-02 16:42:09 +02:00
Emmanuel Hocdet
4aa615ff6b MEDIUM: ssl: ctx_set_version/ssl_set_version func for methodVersions table
This patch cleanup the usage of set_version func with a more suitable name:
ctx_set_version. It introduce ssl_set_version func (unused for the moment).
2017-06-02 16:41:57 +02:00
Emmanuel Hocdet
ecb0e234b9 REORG: ssl: move defines and methodVersions table upper
It will used in ssl_sock_switchctx_cbk.
2017-06-02 16:41:36 +02:00
Willy Tarreau
f57a29a1cd [RELEASE] Released version 1.8-dev2
Released version 1.8-dev2 with the following main changes :
    - CLEANUP: server: moving netinet/tcp.h inclusion
    - DOC: changed "block"(deprecated) examples to http-request deny
    - DOC: add few comments to examples.
    - DOC: update sample code for PROXY protocol
    - DOC: mention lighttpd 1.4.46 implements PROXY
    - MINOR server: Restrict dynamic cookie check to the same proxy.
    - DOC: stick-table is available in frontend sections
    - BUG/MINOR: server : no transparent proxy for DragonflyBSD
    - BUILD/MINOR: stats: remove unexpected argument to stats_dump_json_header()
    - BUILD/MINOR: tools: fix build warning in debug_hexdump()
    - BUG/MINOR: dns: Wrong address family used when creating IPv6 sockets.
    - BUG/MINOR: config: missing goto out after parsing an incorrect ACL character
    - BUG/MINOR: arg: don't try to add an argument on failed memory allocation
    - MEDIUM: server: Inherit CLI weight changes and agent-check weight responses
    - BUG/MEDIUM: arg: ensure that we properly unlink unresolved arguments on error
    - BUG/MEDIUM: acl: don't free unresolved args in prune_acl_expr()
    - BUG/MEDIUM: servers: unbreak server weight propagation
    - MINOR: lua: ensure the memory allocator is used all the time
    - MINOR: cli: Add a command to send listening sockets.
    - MINOR: global: Add an option to get the old listening sockets.
    - MINOR: tcp: When binding socket, attempt to reuse one from the old proc.
    - MINOR: doc: document the -x flag
    - MINOR: proxy: Don't close FDs if not our proxy.
    - MINOR: socket transfer: Set a timeout on the socket.
    - MINOR: systemd wrapper: add support for passing the -x option.
    - BUG/MINOR: server: Fix a wrong error message during 'usesrc' keyword parsing.
    - BUG/MAJOR: Broken parsing for valid keywords provided after 'source' setting.
    - CLEANUP: logs: typo: simgle => single
    - BUG/MEDIUM: acl: proprely release unused args in prune_acl_expr()
    - MEDIUM: config: don't check config validity when there are fatal errors
    - BUG/MAJOR: Use -fwrapv.
    - BUG/MINOR: server: don't use "proxy" when px is really meant.
    - BUG/MEDIUM: http: Drop the connection establishment when a redirect is performed
    - BUG/MINOR: server: missing default server 'resolvers' setting duplication.
    - MINOR: server: Extract the code responsible of copying default-server settings.
    - MINOR: server: Extract the code which finalizes server initializations after 'server' lines parsing.
    - MINOR: server: Add 'server-template' new keyword supported in backend sections.
    - MINOR: server: Add server_template_init() function to initialize servers from a templates.
    - DOC: Add documentation for new "server-template" keyword.
    - DOC: add layer 4 links/cross reference to "block" keyword.
    - DOC: errloc/errorloc302/errorloc303 missing status codes.
    - BUG/MEDIUM: lua: memory leak
    - CLEANUP: lua: remove test
    - BUG/MINOR: hash-balance-factor isn't effective in certain circumstances
    - BUG/MINOR: change header-declared function to static inline
    - REORG: spoe: move spoe_encode_varint / spoe_decode_varint from spoe to common
    - MINOR: Add binary encoding request header sample fetch
    - MINOR: proto-http: Add sample fetch wich returns all HTTP headers
    - MINOR: Add ModSecurity wrapper as contrib
    - BUG/MINOR: ssl: fix warnings about methods for opensslv1.1.
    - DOC: update RFC references
    - CONTRIB: tcploop: add action "X" to execute a command
    - MINOR: server: cli: Add server FQDNs to server-state file and stats socket.
    - BUG/MINOR: contrib/mod_security: fix build on FreeBSD
    - BUG/MINOR: checks: don't send proxy protocol with agent checks
    - MINOR: ssl: add prefer-client-ciphers
    - MEDIUM: ssl: revert ssl/tls version settings relative to default-server.
    - MEDIUM: ssl: ssl_methods implementation is reworked and factored for min/max tlsxx
    - MEDIUM: ssl: calculate the real min/max TLS version and find holes
    - MINOR: ssl: support TLSv1.3 for bind and server
    - MINOR: ssl: show methods supported by openssl
    - MEDIUM: ssl: add ssl-min-ver and ssl-max-ver parameters for bind and server
    - MEDIUM: ssl: ssl-min-ver and ssl-max-ver compatibility.
    - CLEANUP: retire obsoleted USE_GETSOCKNAME build option
    - BUG/MAJOR: dns: Broken kqueue events handling (BSD systems).
    - MINOR: sample: Add b64dec sample converter
    - BUG/MEDIUM: lua: segfault if a converter or a sample doesn't return anything
    - MINOR: cli: add ACCESS_LVL_MASK to store the access level
    - MINOR: cli: add 'expose-fd listeners' to pass listeners FDs
    - MEDIUM: proxy: zombify proxies only when the expose-fd socket is bound
    - MEDIUM: ssl: add basic support for OpenSSL crypto engine
    - MAJOR: ssl: add openssl async mode support
    - MEDIUM: ssl: handle multiple async engines
    - MINOR: boringssl: basic support for OCSP Stapling
    - MEDIUM: mworker: replace systemd mode by master worker mode
    - MEDIUM: mworker: handle reload and signals
    - MEDIUM: mworker: wait mode on reload failure
    - MEDIUM: mworker: try to guess the next stats socket to use with -x
    - MEDIUM: mworker: exit-on-failure option
    - MEDIUM: mworker: workers exit when the master leaves
    - DOC: add documentation for the master-worker mode
    - MEDIUM: systemd: Type=forking in unit file
    - MAJOR: systemd-wrapper: get rid of the wrapper
    - MINOR: log: Add logurilen tunable.
    - CLEANUP: server.c: missing prototype of srv_free_dns_resolution
    - MINOR: dns: smallest DNS fqdn size
    - MINOR: dns: functions to manage memory for a DNS resolution structure
    - MINOR: dns: parse_server() now uses srv_alloc_dns_resolution()
    - REORG: dns: dns_option structure, storage of hostname_dn
    - MINOR: dns: new snr_check_ip_callback function
    - MAJOR: dns: save a copy of the DNS response in struct resolution
    - MINOR: dns: implement a LRU cache for DNS resolutions
    - MINOR: dns: make 'ancount' field to match the number of saved records
    - MINOR: dns: introduce roundrobin into the internal cache (WIP)
    - MAJOR/REORG: dns: DNS resolution task and requester queues
    - BUILD: ssl: fix build with OPENSSL_NO_ENGINE
    - MINOR: Add Mod Defender integration as contrib
    - CLEANUP: str2mask return code comment: non-zero -> zero.
    - MINOR: tools: make debug_hexdump() use a const char for the string
    - MINOR: tools: make debug_hexdump() take a string prefix
    - CLEANUP: connection: remove unused CO_FL_WAIT_DATA
2017-06-02 15:59:51 +02:00
Willy Tarreau
2686dcad1e CLEANUP: connection: remove unused CO_FL_WAIT_DATA
Very early in the connection rework process leading to v1.5-dev12, commit
56a77e5 ("MEDIUM: connection: complete the polling cleanups") marked the
end of use for this flag which since was never set anymore, but it continues
to be tested. Let's kill it now.
2017-06-02 15:50:27 +02:00
Willy Tarreau
ed936c5d37 MINOR: tools: make debug_hexdump() take a string prefix
When dumping data at various places in the code, it's hard to figure
what is present where. To make this easier, this patch slightly modifies
debug_hexdump() to take a prefix string which is prepended in front of
each output line.
2017-06-02 15:49:31 +02:00
Willy Tarreau
9faef1e391 MINOR: tools: make debug_hexdump() use a const char for the string
There's no reason the string to be dumped should be a char *, it's
a const.
2017-06-02 15:49:31 +02:00
Jarno Huuskonen
577d5ac8ae CLEANUP: str2mask return code comment: non-zero -> zero. 2017-06-02 15:43:46 +02:00
Dragan Dosen
59bb97a192 MINOR: Add Mod Defender integration as contrib
This is a service that talks SPOE protocol and uses the Mod Defender (a
NAXSI clone) functionality to detect HTTP attacks. It returns a HTTP
status code to indicate whether the request is suspicious or not, based on
NAXSI rules. The value of the returned code can be used in HAProxy rules
to determine if the HTTP request should be blocked/rejected.
2017-06-02 12:14:55 +02:00
Emmanuel Hocdet
9ac143b607 BUILD: ssl: fix build with OPENSSL_NO_ENGINE
Build is broken with openssl library without support of engin (like boringssl).
Add OPENSSL_NO_ENGINE flag to fix that.
2017-06-02 12:07:48 +02:00
Baptiste Assmann
201c07f681 MAJOR/REORG: dns: DNS resolution task and requester queues
This patch is a major upgrade of the internal run-time DNS resolver in
HAProxy and it brings the following 2 main changes:

1. DNS resolution task

Up to now, DNS resolution was triggered by the health check task.
From now, DNS resolution task is autonomous. It is started by HAProxy
right after the scheduler is available and it is woken either when a
network IO occurs for one of its nameserver or when a timeout is
matched.

From now, this means we can enable DNS resolution for a server without
enabling health checking.

2. Introduction of a dns_requester structure

Up to now, DNS resolution was purposely made for resolving server
hostnames.
The idea, is to ensure that any HAProxy internal object should be able
to trigger a DNS resolution. For this purpose, 2 things has to be done:
  - clean up the DNS code from the server structure (this was already
    quite clean actually) and clean up the server's callbacks from
    manipulating too much DNS resolution
  - create an agnostic structure which allows linking a DNS resolution
    and a requester of any type (using obj_type enum)

3. Manage requesters through queues

Up to now, there was an uniq relationship between a resolution and it's
owner (aka the requester now). It's a shame, because in some cases,
multiple objects may share the same hostname and may benefit from a
resolution being performed by a third party.
This patch introduces the notion of queues, which are basically lists of
either currently running resolution or waiting ones.

The resolutions are now available as a pool, which belongs to the resolvers.
The pool has has a default size of 64 resolutions per resolvers and is
allocated at configuration parsing.
2017-06-02 11:58:54 +02:00
Baptiste Assmann
8ea0bcc911 MINOR: dns: introduce roundrobin into the internal cache (WIP)
This patch introduces a bit of roundrobin in the records stored in our
local cache.
Purpose is to allow some kind of distribution of the IPs found in a
response.
Note that distribution properly applies only when the IP used by many
requesters disappear and is replaced by an other one.
2017-06-02 11:40:39 +02:00
Baptiste Assmann
69fce67b56 MINOR: dns: make 'ancount' field to match the number of saved records
ancount is the number of answers available in a DNS response.
Before this patch, HAProxy used to store the ancount found in the buffer
(sent by the DNS server).
Unfortunately, this is now inaccurate and does not correspond to the
number of records effectively stored in our local version of the
response. In Example, the CNAMEs are not stored.

This patch updates ancount field in to make it match what is effectively
stored in our version.
2017-06-02 11:40:16 +02:00
Baptiste Assmann
fa4a663095 MINOR: dns: implement a LRU cache for DNS resolutions
Introduction of a DNS response LRU cache in HAProxy.

When a positive response is received from a DNS server, HAProxy stores
it in the struct resolution and then also populates a LRU cache with the
response.
For now, the key in the cache is a XXHASH64 of the hostname in the
domain name format concatened to the query type in string format.
2017-06-02 11:40:01 +02:00
Baptiste Assmann
729c901c3f MAJOR: dns: save a copy of the DNS response in struct resolution
Prior this patch, the DNS responses were stored in a pre-allocated
memory area (allocated at HAProxy's startup).
The problem is that this memory is erased for each new DNS responses
received and processed.

This patch removes the global memory allocation (which was not thread
safe by the way) and introduces a storage of the dns response  in the
struct
resolution.
The memory in the struct resolution is also reserved at start up and is
thread safe, since each resolution structure will have its own memory
area.

For now, we simply store the response and use it atomically per
response per server.
2017-06-02 11:30:21 +02:00
Baptiste Assmann
fb7091e213 MINOR: dns: new snr_check_ip_callback function
In the process of breaking links between dns_* functions and other
structures (mainly server and a bit of resolution), the function
dns_get_ip_from_response needs to be reworked: it now can call
"callback" functions based on resolution's owner type to allow modifying
the way the response is processed.

For now, main purpose of the callback function is to check that an IP
address is not already affected to an element of the same type.

For now, only server type has a callback.
2017-06-02 11:28:14 +02:00
Baptiste Assmann
42746373eb REORG: dns: dns_option structure, storage of hostname_dn
This patch introduces a some re-organisation around the DNS code in
HAProxy.

1. make the dns_* functions less dependent on 'struct server' and 'struct resolution'.

With this in mind, the following changes were performed:
- 'struct dns_options' has been removed from 'struct resolution' (well,
  we might need it back at some point later, we'll see)
  ==> we'll use the 'struct dns_options' from the owner of the resolution
- dns_get_ip_from_response(): takes a 'struct dns_options' instead of
  'struct resolution'
  ==> so the caller can pass its own dns options to get the most
      appropriate IP from the response
- dns_process_resolve(): struct dns_option is deduced from new
  resolution->requester_type parameter

2. add hostname_dn and hostname_dn_len into struct server

In order to avoid recomputing a server's hostname into its domain name
format (and use a trash buffer to store the result), it is safer to
compute it once at configuration parsing and to store it into the struct
server.
In the mean time, the struct resolution linked to the server doesn't
need anymore to store the hostname in domain name format. A simple
pointer to the server one will make the trick.

The function srv_alloc_dns_resolution() properly manages everything for
us: memory allocation, pointer updates, etc...

3. move resolvers pointer into struct server

This patch makes the pointer to struct dns_resolvers from struct
dns_resolution obsolete.
Purpose is to make the resolution as "neutral" as possible and since the
requester is already linked to the resolvers, then we don't need this
information anymore in the resolution itself.
2017-06-02 11:26:48 +02:00
Baptiste Assmann
4f91f7ea59 MINOR: dns: parse_server() now uses srv_alloc_dns_resolution()
In order to make DNS code more consistent, the function parse_server()
now uses srv_alloc_dns_resolution() to set up a server and its
resolution.
2017-06-02 11:20:50 +02:00
Baptiste Assmann
81ed1a0516 MINOR: dns: functions to manage memory for a DNS resolution structure
A couple of new functions to allocate and free memory for a DNS
resolution structure. Main purpose is to to make the code related to DNS
more consistent.
They allocate or free memory for the structure itself. Later, if needed,
they should also allocate / free the buffers, etc, used by this structure.
They don't set/unset any parameters, this is the role of the caller.

This patch also implement calls to these function eveywhere it is
required.
2017-06-02 11:20:29 +02:00
Baptiste Assmann
d0aa6d2399 MINOR: dns: smallest DNS fqdn size
global variable used to define the size of the smallest fqdn possible.
2017-06-02 11:20:07 +02:00
Baptiste Assmann
9d41fe7f98 CLEANUP: server.c: missing prototype of srv_free_dns_resolution
Prototype for the function srv_free_dns_resolution() missing at the top
of the file.
2017-06-02 11:18:28 +02:00
Stéphane Cottin
23e9e93128 MINOR: log: Add logurilen tunable.
The default len of request uri in log messages is 1024. In some use
cases, you need to keep the long trail of GET parameters. The only
way to increase this len is to recompile with DEFINE=-DREQURI_LEN=2048.

This commit introduces a tune.http.logurilen configuration directive,
allowing to tune this at runtime.
2017-06-02 11:06:36 +02:00
William Lallemand
a6cfa9098e MAJOR: systemd-wrapper: get rid of the wrapper
The master worker mode obsoletes the systemd-wrapper, to ensure that
nobody uses it anymore, the code has been removed.
2017-06-02 10:56:32 +02:00
William Lallemand
6db884d961 MEDIUM: systemd: Type=forking in unit file
Adding Type=forking in the unit file ensure better monitoring from
systemd. During a systemctl start the tool is able to return an error if
it didn't work with this option.
2017-06-02 10:56:32 +02:00
William Lallemand
e202b1e951 DOC: add documentation for the master-worker mode 2017-06-02 10:56:32 +02:00
William Lallemand
e20b6a62f8 MEDIUM: mworker: workers exit when the master leaves
This patch ensure that the children will exit when the master quits,
even if the master didn't send any signal.

The master and the workers are connected through a pipe, when the pipe
closes the children leave.
2017-06-02 10:56:32 +02:00
William Lallemand
69f9b3bfa4 MEDIUM: mworker: exit-on-failure option
This option exits every workers when one of the current workers die.

It allows you to monitor the master process in order to relaunch
everything on a failure.

For example it can be used with systemd and Restart=on-failure in a spec
file.
2017-06-02 10:56:32 +02:00
William Lallemand
85b0bd9e54 MEDIUM: mworker: try to guess the next stats socket to use with -x
In master worker mode, you can't specify the stats socket where you get
your listeners FDs on a reload, because the command line of the re-exec
is launched by the master.

To solve the problem, when -x is found on the command line, its
parameter is rewritten on a reexec with the first stats socket with the
capability to send sockets. It tries to reuse the original parameter if
it has this capability.
2017-06-02 10:56:32 +02:00
William Lallemand
cb11fd2c7a MEDIUM: mworker: wait mode on reload failure
In Master Worker mode, when the reloading of the configuration fail,
the process is exiting leaving the children without their father.

To handle this, we register an exit function with atexit(3), which is
reexecuting the binary in a special mode. This particular mode of
HAProxy don't reload the configuration, it only loops on wait().
2017-06-02 10:56:32 +02:00
William Lallemand
73b85e75b3 MEDIUM: mworker: handle reload and signals
The master-worker will reload itself on SIGUSR2/SIGHUP

It's inherited from the systemd wrapper, when the SIGUSR2 signal is
received, the master process will reexecute itself with the -sf flag
followed by the PIDs of the children.

In the systemd wrapper, the children were using a pipe to notify when
the config has been parsed and when the new process is ready. The goal
was to ensure that the process couldn't reload during the parsing of the
configuration, before signals were send to old process.

With the new mworker model, the master parses the configuration and is
aware of all the children. We don't need a pipe, but we need to block
those signals before the end of a reload, to ensure that the process
won't be killed during a reload.

The SIGUSR1 signal is forwarded to the children to soft-stop HAProxy.

The SIGTERM and SIGINT signals are forwarded to the children in order to
terminate them.
2017-06-02 10:56:32 +02:00
William Lallemand
095ba4c242 MEDIUM: mworker: replace systemd mode by master worker mode
This commit remove the -Ds systemd mode in HAProxy in order to replace
it by a more generic master worker system. It aims to replace entirely
the systemd wrapper in the near future.

The master worker mode implements a new way of managing HAProxy
processes. The master is in charge of parsing the configuration
file and is responsible for spawning child processes.

The master worker mode can be invoked by using the -W flag.  It can be
used either in background mode (-D) or foreground mode. When used in
background mode, the master will fork to daemonize.

In master worker background mode, chroot, setuid and setgid are done in
each child rather than in the master process, because the master process
will still need access to filesystem to reload the configuration.
2017-06-02 10:56:32 +02:00
Emmanuel Hocdet
2c32d8f379 MINOR: boringssl: basic support for OCSP Stapling
Use boringssl SSL_CTX_set_ocsp_response to set OCSP response from file with
'.ocsp' extension. CLI update is not supported.
2017-05-27 07:59:34 +02:00
Emeric Brun
3854e0102b MEDIUM: ssl: handle multiple async engines
This patch adds the support of a maximum of 32 engines
in async mode.

Some tests have been done using 2 engines simultaneously.

This patch also removes specific 'async' attribute from the connection
structure. All the code relies only on Openssl functions.
2017-05-27 07:12:27 +02:00
Grant Zhang
fa6c7ee702 MAJOR: ssl: add openssl async mode support
ssl-mode-async is a global configuration parameter which enables
asynchronous processing in OPENSSL for all SSL connections haproxy
handles. With SSL_MODE_ASYNC set, TLS I/O operations may indicate a
retry with SSL_ERROR_WANT_ASYNC with this mode set if an asynchronous
capable engine is used to perform cryptographic operations. Currently
async mode only supports one async-capable engine.

This is the latest version of the patchset which includes Emeric's
updates :
  - improved async fd cleaning when openssl reports an fd to delete
  - prevent conn_fd_handler from calling SSL_{read,write,handshake} until
    the async fd is ready, as these operations are very slow and waste CPU
  - postpone of SSL_free to ensure the async operation can complete and
    does not cause a dereference a released SSL.
  - proper removal of async fd from the fdtab and removal of the unused async
    flag.
2017-05-27 07:05:54 +02:00
Grant Zhang
872f9c2139 MEDIUM: ssl: add basic support for OpenSSL crypto engine
This patch adds the global 'ssl-engine' keyword. First arg is an engine
identifier followed by a list of default_algorithms the engine will
operate.

If the openssl version is too old, an error is reported when the option
is used.
2017-05-27 07:05:00 +02:00
William Lallemand
7f80eb2383 MEDIUM: proxy: zombify proxies only when the expose-fd socket is bound
When HAProxy is running with multiple processes and some listeners
arebound to processes, the unused sockets were not closed in the other
processes. The aim was to be able to send those listening sockets using
the -x option.

However to ensure the previous behavior which was to close those
sockets, we provided the "no-unused-socket" global option.

This patch changes this behavior, it will close unused sockets which are
not in the same process as an expose-fd socket, making the
"no-unused-socket" option useless.

The "no-unused-socket" option was removed in this patch.
2017-05-27 07:02:25 +02:00
William Lallemand
f6975e9f76 MINOR: cli: add 'expose-fd listeners' to pass listeners FDs
This patch changes the stats socket rights for allowing the sending of
listening sockets.

The previous behavior was to allow any unix stats socket with admin
level to send sockets. It's not possible anymore, you have to set this
option to activate the socket sending.

Example:
   stats socket /var/run/haproxy4.sock mode 666 expose-fd listeners level user process 4
2017-05-27 07:02:17 +02:00
William Lallemand
07a62f7a7e MINOR: cli: add ACCESS_LVL_MASK to store the access level
The current level variable use only 2 bits for storing the 3 access
level (user, oper and admin).

This patch add a bitmask which allows to use the remaining bits for
other usage.
2017-05-27 07:02:06 +02:00
Thierry FOURNIER
fd80df11c3 BUG/MEDIUM: lua: segfault if a converter or a sample doesn't return anything
In the case of a Lua sample-fetch or converter doesn't return any
value, an acces outside the Lua stack can be performed. This patch
check the stack size before converting the top value to a HAProxy
internal sample.

A workaround consist to check that a value value is always returned
with sample fetches and converters.

This patch should be backported in the version 1.6 and 1.7
2017-05-12 16:46:26 +02:00
Holger Just
1bfc24ba03 MINOR: sample: Add b64dec sample converter
Add "b64dec" as a new converter which can be used to decode a base64
encoded string into its binary representation. It performs the inverse
operation of the "base64" converter.
2017-05-12 15:56:52 +02:00
Frédéric Lécaille
64920538fc BUG/MAJOR: dns: Broken kqueue events handling (BSD systems).
Some DNS related network sockets were closed without unregistering their file
descriptors from their underlying kqueue event sets. This patch replaces calls to
close() by fd_delete() calls to that to delete such events attached to DNS
network sockets from the kqueue before closing the sockets.

The bug was introduced by commit 26c6eb8 ("BUG/MAJOR: dns: restart sockets
after fork()") which was backported in 1.7 so this fix has to be backported
there as well.

Thanks to Jim Pingle who reported it and indicated the faulty commit, and
to Lukas Tribus for the trace showing the bad file descriptor.
2017-05-12 15:49:05 +02:00
Dmitry Sivachenko
047000a8bd CLEANUP: retire obsoleted USE_GETSOCKNAME build option
The last user of this option disappeared in 1.5-dev10.
2017-05-12 15:49:05 +02:00
Emmanuel Hocdet
abd323395f MEDIUM: ssl: ssl-min-ver and ssl-max-ver compatibility.
In haproxy < 1.8, no-sslv3/no-tlsv1x are ignored when force-sslv3/force-tlsv1x
is used (without warning). With this patch, no-sslv3/no-tlsv1x are ignored when
ssl-min-ver or ssl-max-ver is used (with warning).
When all SSL/TLS versions are disable: generate an error, not a warning.
example: ssl-min-ver TLSV1.3 (or force-tlsv13) with a openssl <= 1.1.0.
2017-05-12 15:49:05 +02:00
Emmanuel Hocdet
e1c722b5e8 MEDIUM: ssl: add ssl-min-ver and ssl-max-ver parameters for bind and server
'ssl-min-ver' and 'ssl-max-ver' with argument SSLv3, TLSv1.0, TLSv1.1, TLSv1.2
or TLSv1.3 limit the SSL negotiation version to a continuous range. ssl-min-ver
and ssl-max-ver should be used in replacement of no-tls* and no-sslv3. Warning
and documentation are set accordingly.
2017-05-12 15:49:05 +02:00
Emmanuel Hocdet
50e25e1dbc MINOR: ssl: show methods supported by openssl
TLS v1.3 incoming, SSLv3 will disappears: it could be useful to list
all methods supported by haproxy/openssl (with -vvv).
2017-05-12 15:49:05 +02:00
Emmanuel Hocdet
42fb980e53 MINOR: ssl: support TLSv1.3 for bind and server
This patch add 'no-tlsv13' and 'force-tlsv13' configuration. This is
only useful with openssl-dev and boringssl.
2017-05-12 15:49:05 +02:00
Emmanuel Hocdet
b4e9ba4b36 MEDIUM: ssl: calculate the real min/max TLS version and find holes
Plan is to add min-tlsxx max-tlsxx configuration, more consistent than no-tlsxx.
Find the real min/max versions (openssl capabilities and haproxy configuration)
and generate warning with bad versions range.
'no-tlsxx' can generate 'holes':
"The list of protocols available can be further limited using the SSL_OP_NO_X
options of the SSL_CTX_set_options or SSL_set_options functions. Clients should
avoid creating 'holes' in the set of protocols they support, when disabling a
protocol, make sure that you also disable either all previous or all subsequent
protocol versions. In clients, when a protocol version is disabled without
disabling all previous protocol versions, the effect is to also disable all
subsequent protocol versions."
To not break compatibility, "holes" is authorized with warning, because openssl
1.1.0 and boringssl deal with it (keep the upper or lower range depending the
case and version).
2017-05-12 15:49:04 +02:00
Emmanuel Hocdet
5db33cbdc4 MEDIUM: ssl: ssl_methods implementation is reworked and factored for min/max tlsxx
Plan is to add min-tlsxx max-tlsxx configuration, more consistent than no-tlsxx.
This patch introduce internal min/max and replace force-tlsxx implementation.
SSL method configuration is store in 'struct tls_version_filter'.
SSL method configuration to openssl setting is abstract in 'methodVersions' table.
With openssl < 1.1.0, SSL_CTX_set_ssl_version is used for force (min == max).
With openssl >= 1.1.0, SSL_CTX_set_min/max_proto_version is used.
2017-05-12 15:49:04 +02:00
Emmanuel Hocdet
6cb2d1e963 MEDIUM: ssl: revert ssl/tls version settings relative to default-server.
Plan is to add min-tlsxx max-tlsxx configuration, more consistent than no-tlsxx.
min-tlsxx and max-tlsxx can be overwrite on local definition. This directives
should be the only ones needed in default-server.
To simplify next patches (rework of tls versions settings with min/max) all
ssl/tls version settings relative to default-server are reverted first:
remove: 'sslv3', 'tls*', 'no-force-sslv3', 'no-force-tls*'.
remove from default-server: 'no-sslv3', 'no-tls*'.
Note:
. force-tlsxx == min-tlsxx + max-tlsxx : would be ok in default-server.
. no-tlsxx is keep for compatibility: should not be propagated to default-server.
2017-05-12 15:49:04 +02:00
Lukas Tribus
53ae85c38e MINOR: ssl: add prefer-client-ciphers
Currently we unconditionally set SSL_OP_CIPHER_SERVER_PREFERENCE [1],
which may not always be a good thing.

The benefit of server side cipher prioritization may not apply to all
cases out there, and it appears that the various SSL libs are going away
from this recommendation ([2], [3]), as insecure ciphers suites are
properly blacklisted/removed and honoring the client's preference is
more likely to improve user experience  (for example using SW-friendly
ciphers on devices without HW AES support).

This is especially true for TLSv1.3, which will restrict the cipher
suites to just AES-GCM and Chacha20/Poly1305.

Apache [4], nginx [5] and others give admins full flexibility, we should
as well.

The initial proposal to change the current default and add a
"prefer-server-ciphers" option (as implemented in e566ecb) has been
declined due to the possible security impact.

This patch implements prefer-client-ciphers without changing the defaults.

[1] https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html
[2] https://github.com/openssl/openssl/issues/541
[3] https://github.com/libressl-portable/portable/issues/66
[4] https://httpd.apache.org/docs/2.0/en/mod/mod_ssl.html#sslhonorcipherorder
[5] https://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_prefer_server_ciphers
2017-05-12 15:49:04 +02:00