Commit Graph

105 Commits

Author SHA1 Message Date
Michael Klishin 135d043344 Minor log message corrections 2017-01-17 14:35:23 +00:00
Daniil Fedotov 2b412bdb7d Add/delete certificate providers in realtime 2017-01-17 14:35:23 +00:00
Daniil Fedotov 5c0cab02f7 Certificate name in attributes field 2017-01-17 14:35:23 +00:00
Daniil Fedotov ba624acd79 Refactor modules 2017-01-17 14:35:23 +00:00
Daniil Fedotov a615136ff2 Pluggable trust stores: tests are passing 2017-01-17 14:35:23 +00:00
Daniil Fedotov be1ca68aae Pluggable behaviour for CA cert source 2017-01-17 14:34:06 +00:00
Jean-Sébastien Pédron 8582ff60fa rabbit_trust_store_app: Import a copy of lists:droplast()
This function was introduced in Erlang 17.x so it's missing in Erlang
R16B03.

[#135953005]
2016-12-12 18:14:42 +01:00
Jean-Sébastien Pédron 2d4ad26823 rabbit_trust_store_app: Do not use option `partial_chain` on Erlang R16B03
... and Erlang 17.x up-to 17.2.

[#135953005]
2016-12-12 18:14:19 +01:00
Jean-Sébastien Pédron 2c2dda7154 Move from .app.src to Makefile variables
This is the recommended way with Erlang.mk.

By default, the version is inherited from rabbitmq-server-release when
the source archive is created, or computed from git-describe(1) (see
`rabbitmq-components.mk`). One can override the version from the command
line by setting the `PROJECT_VERSION` variable.

[#130992027]
2016-12-06 16:59:22 +01:00
Jean-Sébastien Pédron a8e6e56c16 rabbitmq_trust_store.app: Depend on rabbit_common 2016-09-20 12:48:11 +02:00
kjnilsson 5935bedaf4 Validate the peer in a presented certificate chain 2016-06-23 13:28:33 +01:00
Michael Klishin 7bd72eb2f3 Don't assume at least 1 certificate was deleted
With duplicate certificates, when one of them is removed 0 would
be returned, causing a badmatch.
2016-06-21 23:14:13 +03:00
kjnilsson 870833131c Function to list loaded certs 2016-06-21 16:01:01 +01:00
Michael Klishin 4c24445944 Cosmetics 2016-06-20 23:35:30 +03:00
kjnilsson 8c1e1155d1 handle invalid and badly formatted certificatates
- add logging
2016-06-20 18:04:44 +01:00
kjnilsson 9ea50eff8f ensure that a replaced certificate with the same
name is picked up
    - add test for replacing cert with same name
    - disable use of ssl session cache
    - gitignore
    - document use of reuse_sessions
2016-05-18 10:16:52 +01:00
Michael Klishin 181798f5c5 Merge branch 'rabbitmq-trust-store-9' 2016-05-07 07:26:01 +08:00
Michael Klishin 5348a61f02 Merge branch 'rabbitmq-trust-store-8' 2016-05-07 07:14:26 +08:00
Michael Klishin cb8f109b03 Merge branch 'rabbitmq-trust-store-12' 2016-05-07 07:12:25 +08:00
kjnilsson b8e9faaced correct naming according to OTP documentation 2016-05-06 12:48:01 +01:00
kjnilsson 950653bf75 handle code_change better 2016-05-06 10:47:50 +01:00
kjnilsson 76ce3d9ebd rename whitelisted_ to is_whitelisted 2016-05-06 10:36:20 +01:00
kjnilsson c165bd4183 ensure binary directory paths are handled 2016-05-06 10:23:28 +01:00
kjnilsson 3ef69e6ab0 Move the default refresh interval value to .app file 2016-05-03 16:50:40 +01:00
kjnilsson c09def8e8f Replace usages of get_env/1 with get_env/2 2016-05-03 15:44:46 +01:00
Michael Klishin b56e18c380 Support intervals that are integers
not just {seconds, Val}.
2016-04-17 18:59:23 +03:00
Michael Klishin 0168d8f83e Don't fail if the verify_fun is configured; log a warning instead 2016-04-17 18:23:29 +03:00
Joseph Yiasemides 8e13ca81ef Remove the `persistent` option passed to `application:env_set/4`
This isn't available on Erlang R16B03, making broker start fail, so
remove this option since it is not needed.
2016-03-21 18:16:55 +01:00
Joseph Yiasemides e2c61c0e37 Revert SSL socket options when trust-store plugin is disabled
That is, SSL socket options that reside in the broker's OTP
environment. These are reverted in the plugin's `cleanup`
procedure. Indirect dependencies can then be restarted without their
SSL listeners interfacing with the trust-store.
2016-03-03 15:35:33 +01:00
Michael Klishin a0e35b52da Minor license header correction 2016-03-03 15:17:48 +03:00
Michael Klishin dafb1783ea Wording 2016-03-03 15:17:43 +03:00
Joseph Yiasemides c2d65e3444 Save initial TLS configuration options to application environment
TLS sockets (OTP's SSL) must be configured to interface with the
Trust-Store before they start listening. The boot-steps make sure that
the trust store makes the necessary amendments to the configuration
options in time. We put the initial SSL configuration options in the
OTP Application environment so that they can be restored if the plugin
is disabled.
2016-02-26 17:45:25 +01:00
Joseph Yiasemides 973bc4b45a Build directories in a portable way (i.e. Linux & Windows)
Only call procedures from the file/directory libraries rather than
appending a "/" to describe directories.
2016-02-24 15:02:50 +01:00
Joseph Yiasemides 4a1c75e67f Default to a whitelist directory that is consistent with others
Don't default to the (user's) home directory, this is far from ideal
on Linux systems, but worse with Windows because a home directory
doesn't exist there. Instead we dismantle the Mnesia directory and
root the default whitelist directory nearby. This is because Rabbit
doesn't use environment variables (e.g. RABBITMQ_HOME and
RABBITMQ_BASE) elsewhere in the source, as the definitive place to
root directories for application/pluging data.

NOTE: paths continue to append a "/" so commit is not Windows
friendly.
2016-02-24 11:40:31 +01:00
Joseph Yiasemides 0448d30c16 Build a match specification which matches on just one ETS entry
The function literal which was being passed to build a match
specification was missing a guard to select just ONE filemane from
ETS.
2016-02-23 11:04:55 +01:00
Joseph Yiasemides 1bf2a90130 Match on a `1` not `true` upon ETS select delete
This fixes a bug when removing certificate details, which would cause
the trust-store server to crash, though the test set succeeded because
it got restarted by it's supervisor.
2016-02-22 16:03:34 +01:00
Joseph Yiasemides 59de1f0598 Move behaviour declaration so that interfaces are clearer 2016-02-16 14:21:00 +01:00
Joseph Yiasemides 51809260e9 Document more in the README 2016-02-16 13:17:57 +01:00
Joseph Yiasemides b2d9455cc3 Change how `refresh_interval` is configured to be in line with README 2016-02-16 10:04:36 +01:00
Joseph Yiasemides c7a38a3ac9 Change configuration option names so that they're more friendly 2016-02-15 08:14:08 +01:00
Joseph Yiasemides 09cbe6bf95 Spruce up OTP Application & Rabbit Plugin specifics
Refactor branching, procedure and case clauses, into simple matches
which'll fail on a bad result. The OTP Application no longer re-checks
preconditions, like the existance of the whitelist directory &
interface module/procedure, which are put in place at Rabbit Plugin
boot.

Fix buggy Application start when we get an empty list of SSL options.
2016-02-12 18:00:52 +01:00
Joseph Yiasemides 3a6af2f19c Configure manual or automatic whitelist refresh
A refresh interval of 0 SECONDS configures the trust-store for manual
whitelist refresh, i.e. to reflect the certificates currently in the
whitelist directory, via call to `rabbit_trust_store:refresh/0`. An
interval >= 1 SECONDS configures automatic refresh, as before, through
timers.

This fixes a related BUG: the degree of time accuracy was not
consistent between the application, server, and test set. The intended
unit is SECONDS, NOT milliseconds, to make configuration more
friendly. I.e. `60` seconds instead of `60 * 1000` milliseconds.
2016-02-12 15:12:26 +01:00
Joseph Yiasemides 0ecda46632 Refresh whitelist with delta between old & new directory contents
Store the filename along with certificate issuer name and serial
number, so as to perform a diff on the directory contents, then only
install and remove those entries which need it. We were deleting all
entries + reading in the entire (newer) contents of the directory when
directory modification time had changed.

Along the way it made more sense to optimise ETS for querying the
whitelist than it did to refresh it: the key is still the
unique/distinctive certificate value (issuer name & serial
number). While installing and removing certificates rely on a
`select`.

The client facing interface, `whitelisted/3`, ultimately makes a call
to the ETS table directly. That is, it no longer goes through the
`trust_store` process, which was unecessary.
2016-02-12 15:12:26 +01:00
Joseph Yiasemides d941a9beff Refresh whitelist only when directory has been modified
Keep the whitelist up-to-date more intelligently: only refresh when
the directory's modification time has changed.
2016-02-12 15:12:26 +01:00
Joseph Yiasemides 628a4227d5 Refresh whitelist to reflect changes in directory after a given period
This commit takes a naive approach: rebuilding the whitelist from
scratch every single time.
2016-02-12 15:12:26 +01:00
Joseph Yiasemides 9e91e2f256 Whitelist with & query an ETS table instead of a list
Building the whitelist with a list is practicle initially but not
performant. Introduce a record `entry` which will contain a filename +
modification time in the whitelist.
2016-02-12 15:12:06 +01:00
Joseph Yiasemides 6f4ee2388d Build whitelisting and querying functionality
This completes the client facing procedure `whitelisted/3` with which
SSL sockets effectively query the trust-store, introducing basic
functionality for the server internals, but simplifies matters by
using a list to store the whitelist information. Error logging for
debugging purposes is removed.
2016-02-03 20:11:11 +01:00
Joseph Yiasemides 206b1e6591 Log the `whitelisted/3` procedure's state for better visibility
A building & testing aid.
2016-02-02 10:51:38 +01:00
Joseph Yiasemides 65f9627b93 Order the `whitelisted/3` clauses from base-like to recursive cases.
The more 'terminal' clauses are listed first, followed by recursive
cases, and end with clauses that lean towards the 'error' end of the
spectrum.
2016-02-01 15:09:51 +01:00
Joseph Yiasemides 3f4094068f Simplify the terminate/shutdown boilerplate
A `stop` procedure isn't necessary if the server will always find
itself in a supervision tree. We trap exits upon initialisation and
handle the reason `shutdown` in the procedure `terminate/2`, instead.
Clean the procedures `handle_call` and `handle_cast`.
2016-02-01 15:07:53 +01:00
Joseph Yiasemides 27b815a354 Improve the interface skeleton in several ways.
* Give the interface procedure a meaningful name.
* Order the procedure's clauses by relevance.
* Log something informative for each clause.
* Dialyzer type & signature for the procedure.
2016-02-01 10:38:13 +01:00
Joseph Yiasemides 0391c0d8a2 Pass whitelist directory down the supervision tree
This is a better choice than having the server retrieve the directory
name itself: (1) we can have guarentees earlier from the application,
and (2) it makes testing easier and clearer.
2016-01-26 17:24:08 +01:00
Joseph Yiasemides 78986e45a9 Start application with a default path to a whitelist directory
The test set would fail before it began because the application
couldn't retrieve a path to a whitlist directory from it's
configuration data. This change makes the application look for
whitelisted certificates in a default directory. The corresponding
test stops the application, changes the configuration, and starts it
to test with given configuration parameters.
2016-01-26 15:57:33 +01:00
Joseph Yiasemides 99182b0828 Complete the OTP Application and boot strapping procedure 2016-01-25 18:48:14 +01:00
Joseph Yiasemides 26b3d2736f Initial commit of Rabbit plugin boilerplate 2016-01-15 14:32:00 +00:00