Commit Graph

386 Commits

Author SHA1 Message Date
Joseph Yiasemides ef25ec09e4 Bolden important words (don't italicize) 2016-02-16 13:21:50 +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 dd59adaf0c Make configuration parameter `interval` more friendly 2016-02-16 09:51:27 +01:00
Michael Klishin 9fb315f182 Update README.md 2016-02-16 09:50:20 +03:00
Joseph Yiasemides 352b1b8c50 Give test cases more time and add a timer to the library test
On occasion, the library test times out, perhaps because it needs
entropy to for randomness when it builds certificates.
2016-02-15 08:47:16 +01:00
Joseph Yiasemides b36082c3f0 Write a README with documentation 2016-02-15 08:33:07 +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 17326129e6 Test the removal and installation of certificates in quick succession
The trust-store relies on deltas of the directory contents,
i.e. filenames, to make mininal changes to the whitelist. Test this.
2016-02-15 07:47:02 +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 a92f993bb3 Introduce timers to change directory modification time
The file system reports time to an accuracy of one second. So, unless
we wait for at least one second, we may see no change in modification
time. The trust-store relies on this to tell when the whitelist needs
to be refreshed.
2016-02-12 15:12:26 +01:00
Joseph Yiasemides b6bcc1627c Add setup and teardown for the test directory (whitelist) 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 10a61adbae Improve test code on several fronts
* Make changing configuration of more than one option easier.
* Distinguish which whitelisted certificate comes from which test
  by using differnt filenames.
* Clean-up after writing out certificate files.
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 b98fe81e71 Test the removal and installation of certificates to be whitelisted
This also introduces testing for a means by which to set an expiry
time, after which the trust-store will refresh its contents to reflect
the underlying directory, so as to keep it up-to-date.
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 6ea7f1a712 Remove needless SSL client options & match on specific error reason
Some unecessary SSL client options meant that it will try to validate
the server certificate. We only want to test that the server tries to
validate the client certificate. These complicated the test set and
raised errors which were difficult to track down: the reason reported
for the client failing to authenticate the server were very similar to
those reported when the server tries to authenticate the client. In
the former case, the server will send a TLS alert to the client,
reporting an "unknown CA".
2016-02-03 14:52:50 +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 48c7f19b3c Indent the first test case properly 2016-01-25 19:06:23 +01:00
Joseph Yiasemides 99182b0828 Complete the OTP Application and boot strapping procedure 2016-01-25 18:48:14 +01:00
Joseph Yiasemides 4d634d85c0 Test trust-store allows clients presenting whitelisted certificates
A simple end-to-end test of the trust-store, in the sense that a .PEM
file is written to a directory from which Rabbit is configured to read
whitelisted certificates, then an AMQP client connects. Note: all
those variables which are necessary but not central to the test are
prefixed with an underscore to distinguish them.
2016-01-22 15:16:05 +01:00
Joseph Yiasemides 9f0baac590 Format test set a little better
Several changes:

* Test names tell us which protocol they use (AMQP). STOMP and MQTT to
  follow.

* Give tests more time to complete as old value proved to be short

* Indicate variables which aren't really involved (but necessary) in a
  given test with a leading underscore

* Format with more stringent guidlines in mind
2016-01-21 13:53:41 +01:00
Joseph Yiasemides 2ea908e2ef Give tests enough time to complete
EUnit will time the tests out after five minutes which isn't enough.
2016-01-20 19:33:35 +01:00
Joseph Yiasemides 4b4c931556 Test path validation failure
This is introduced to test that changes to do whitelisting with the
trust-store keep things working as they stand. Include some necessary
clean-up.
2016-01-20 19:27:25 +01:00
Joseph Yiasemides 4e30ced3fc Test to document successful SSL connection as things stand 2016-01-19 19:15:04 +01:00
Joseph Yiasemides dea6f2bdb5 Arrange to call some of Cowboy's test utilities for certificates
Loïc Hoguin has done a lot of helpful work around the PKI + SLL
applications in OTP to build certificates, authorities, and more all
through Erlang, so no calls from the command-line necessary. At the
end of the day they'd use the same stuff behind the scenes: Open
SLL. But, these make it extreamly convenient to test changes in Rabbit
revolving around TLS + certificates.
2016-01-19 11:43:27 +01:00
Joseph Yiasemides 26b3d2736f Initial commit of Rabbit plugin boilerplate 2016-01-15 14:32:00 +00:00