Commit Graph

384 Commits

Author SHA1 Message Date
Michael Klishin b69fc588c5 Update rabbitmq-components.mk 2017-07-26 02:27:19 +03:00
Michael Klishin 5c9c6c4587 Update rabbitmq-components.mk 2017-06-12 20:18:42 +03:00
Michael Klishin ea5abc3f2b Update rabbitmq-components.mk 2017-06-12 18:35:51 +03:00
Michael Klishin 30d68523e2 Merge branch 'stable' 2017-06-02 18:12:11 +03:00
Michael Klishin 100e72cf10 Update rabbitmq-components.mk 2017-06-02 17:51:38 +03:00
Michael Klishin 7e7015d65c Update rabbitmq-components.mk 2017-06-02 00:43:35 +03:00
Michael Klishin 8342660e3c Update rabbitmq-components.mk 2017-06-01 18:01:54 +03:00
Jean-Sébastien Pédron 3a48f8acbb Merge branch 'stable' 2017-05-16 18:13:30 +02:00
Jean-Sébastien Pédron be61a9dd54 Makefile: Load the new `rabbitmq-early-plugin.mk` early-stage plugin
See the corresponding commit in rabbitmq-common for an explanation.

[#144697185]
2017-05-16 17:39:17 +02:00
Jean-Sébastien Pédron 15449b01c1 Update erlang.mk 2017-05-16 17:39:17 +02:00
Michael Klishin ee168d5ade Merge branch 'stable' 2017-05-10 03:49:56 +03:00
Daniil Fedotov 2604ef9bff Wording 2017-05-08 16:36:56 +01:00
Daniil Fedotov ec5ea5e35e Add a certificate hash to cert_id in the file provider.
[#58]
    Just a file change date can be not enough to detect the certificate
    file change. Add a phash2 hash of a file content to check that certificate
    should be reloaded.
2017-05-08 11:58:40 +01:00
Daniil Fedotov 6f97aadc54 Do not check directory change time.
[#58]
Directory change time is not reliable to detect updates in
certificate files. Time resolution is too big (1 second)
and directory modification time does not update when a file
contents is changed.
2017-05-08 10:30:42 +01:00
Jean-Sébastien Pédron 10c5a8972e Merge branch 'stable' 2017-04-19 16:23:49 +02:00
Jean-Sébastien Pédron 2f20092dbc Update erlang.mk 2017-04-19 12:05:57 +02:00
Michael Klishin e99a9faee0 Merge branch 'stable' 2017-04-02 22:04:24 +03:00
Michael Klishin e16dcee191 (c) year 2017-04-02 21:49:53 +03:00
Ayanda Dube bb2671b446 Typo fix: 'sertificate' -> 'certificate' 2017-03-24 13:25:24 +01:00
Michael Klishin df0ea9a3b3 Ignore test/config_schema_SUITE_data/schema/ 2017-03-20 19:14:52 +03:00
Daniil Fedotov 44d58aba6c Config schema test for plugin
Part of [#141481501]
Moved from rabbitmq-server
2017-03-17 11:02:25 +00:00
Jean-Sébastien Pédron 605cecd816 system_SUITE: Work around file provider issue in `list` testcase
The file provider uses stat(2) which has a resolution of one second in
Erlang. Thus, the refresh may miss the new test certificates if the
creation happens in the same second after the previous refresh.

References #58.
2017-03-15 12:31:22 +01:00
Jean-Sébastien Pédron cf10607ddb system_SUITE: Accept `{error, closed}` as connection failures
With Erlang 18.3, there is a regression which causes the SSL connection
to crash with the following exception:

    ** {badarg,[{ets,update_counter,[1507362,#Ref<0.0.3.9>,-1],[]},
                {ssl_pkix_db,ref_count,3,...

When this exception reaches the connection process before the expected
TLS error, amqp_connection:start() returns `{error, closed}` instead.

Now, testcases tolerate `{error, closed}` as a return value: we know
that the connection was indeed terminated.

Signed-off: Gerhard Lazu <gerhard@rabbitmq.com>
2017-03-13 17:57:22 +01:00
Jean-Sébastien Pédron 7a1086dc29 Merge branch 'stable' 2017-03-08 10:07:01 +01:00
Jean-Sébastien Pédron 800bedeb78 system_SUITE: Wait 5 seconds in wait_for_trust_store_refresh()
... instead of 2 seconds. Hopefully, this increases the chance of test
success.

The real fix would be to explicitely verify that the trust store was
refreshed.
2017-03-08 09:40:29 +01:00
Daniil Fedotov 098f691269 Config schema 2017-02-15 17:45:11 +00:00
Daniil Fedotov c325b36826 3.7.0 json decoding 2017-02-14 18:09:26 +00:00
Michael Klishin 1269ad8517 Update rabbitmq-components.mk 2017-02-11 23:29:44 +03:00
Michael Klishin 0b48819285 Merge branch 'stable' 2017-02-10 21:28:51 +03:00
Michael Klishin 0c29d6417a Example trust store is now under github.com/rabbitmq 2017-02-10 21:28:38 +03:00
Michael Klishin f9d5104344 Merge branch 'stable'
Conflicts:
	.travis.yml
2017-02-10 20:34:53 +03:00
Michael Klishin b449648ea9 `url` in certificate objects should really be `path` 2017-02-10 20:01:53 +03:00
Daniil Fedotov 91f22455de Keep provider state in case of error listing certificates 2017-02-10 15:04:32 +00:00
Michael Klishin 7539f36c33 Ignore certs/* 2017-02-10 17:43:24 +03:00
Michael Klishin 2101dba003 README updates 2017-02-10 16:55:31 +03:00
Michael Klishin 1aeb71ccfe They are not necessarily CA certificates 2017-02-10 16:50:24 +03:00
Michael Klishin 275f2373d2 Ignore *.pyc and *.sqlite3 files 2017-02-10 16:49:54 +03:00
Michael Klishin 40d81b4db6 Merge branch 'stable' into rabbitmq-trust-store-54 2017-02-10 16:46:16 +03:00
Michael Klishin 1586a1a259 Update rabbitmq-components.mk 2017-02-10 11:16:45 +03:00
Michael Klishin 59ae859563 Update rabbitmq-components.mk 2017-02-10 03:06:39 +03:00
Daniil Fedotov 6606c712db Test http provider 2017-02-08 16:07:53 +00:00
Michael Klishin 0df653a310 merge branch 'stable' 2017-02-08 16:58:36 +03:00
Michael Klishin 7fe041a4bd Update rabbitmq-components.mk 2017-02-08 16:48:09 +03:00
Daniil Fedotov fe2a3c3b3c Merge branch 'stable' 2017-02-08 13:36:43 +00:00
Daniil Fedotov e6966dd9df Note about erlang version requirement
Versions prior to 17.3 have issues validating certificate chains
and can crash during `ssl_connection` certificate cache cleanup.
2017-02-08 13:34:53 +00:00
Daniil Fedotov bc40af382d Fix variable names 2017-02-08 13:24:31 +00:00
Daniil Fedotov cfbb905415 Replace maps with proplists 2017-02-08 13:24:31 +00:00
Daniil Fedotov a44fa6ff3c README about HTTP provider 2017-02-08 13:24:31 +00:00
Daniil Fedotov 9090278210 Example Django app to serve certificates 2017-02-08 13:24:31 +00:00
Daniil Fedotov bf50aafbdd HTTP provider for trust store
Fixes #54

Provider will list certificates as JSON, requiring list of objects
with `id` and `url` fields.
JSON root is an object with a single `certificates` field, containing
a list of certificate objects. (some web services require json root to
be object)
Certificates are loaded as PEM encoded files.
2017-02-08 13:24:31 +00:00
Jean-Sébastien Pédron 212fa07661 Travis CI: Disable test on Erlang 18.3
Erlang 18.3 has too many regressions in SSL.

[#135953005]
2017-02-08 13:24:31 +00:00
Jean-Sébastien Pédron ccbf718e9d Travis CI: Import changes from rabbitmq-auth-backend-amqp
In particular, no need to test on Erlang R16B03 and 17.5.
2017-02-08 13:24:31 +00:00
Jean-Sébastien Pédron e9b35b9b5d system_SUITE: Increase timetrap to 3 minutes 2017-02-08 13:24:31 +00:00
Michael Klishin f9206c6466 Update README.md 2017-02-08 13:24:31 +00:00
Daniil Fedotov fe375a69ca Refactor tests to be provider agnostic 2017-02-08 13:24:06 +00:00
Daniil Fedotov 994fbf675f Fix crash when refreshing certificates 2017-02-08 13:23:41 +00:00
Daniil Fedotov 256ee4b352 Make it compile with R16B03 2017-02-07 15:43:52 +00:00
Michael Klishin 1f1ce37d58 merge branch 'stable' 2017-02-06 19:52:26 +03:00
Michael Klishin 84bf7be78b Update rabbitmq-components.mk 2017-02-06 19:24:04 +03:00
Jean-Sébastien Pédron 5b0989378e Update rabbitmq-components.mk 2017-02-02 17:17:24 +01:00
Michael Klishin 11d3b22742 merge branch 'stable' 2017-01-31 18:20:25 +03:00
Michael Klishin 887e857dde Update rabbitmq-components.mk 2017-01-31 18:06:39 +03:00
Michael Klishin 376a978471 Merge branch 'stable'
Conflicts:
	src/rabbit_trust_store_app.erl
2017-01-17 17:53:09 +03:00
Daniil Fedotov 3acc243d40 Naming 2017-01-17 14:35:23 +00:00
Daniil Fedotov a973da27c7 Removing test logs 2017-01-17 14:35:23 +00:00
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 55ea835419 Example certificate provider 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 d19f7e2914 Travis CI: Disable test on Erlang 18.3
Erlang 18.3 has too many regressions in SSL.

[#135953005]
2016-12-12 19:02:27 +01:00
Jean-Sébastien Pédron 68ddf0c89c Merge branch 'stable' 2016-12-12 18:26:45 +01:00
Jean-Sébastien Pédron 81a7772b36 Travis CI: Disable test on Erlang R16B03
Erlang R16B03 doesn't like one of the certificates.

[#135953005]
2016-12-12 18:19:15 +01:00
Jean-Sébastien Pédron 0cee5aaccf system_SUITE: Ensure SSL listeners are stopped
Because if a previous testcase fails, it won't have terminated its own
listener.

[#135953005]
2016-12-12 18:17:45 +01: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 f7beeea916 Travis CI: Import changes from rabbitmq-auth-backend-amqp
In particular, no need to test on Erlang R16B03 and 17.5.
2016-12-09 19:27:21 +01:00
Jean-Sébastien Pédron 85d7b13e03 Merge branch 'stable' 2016-12-09 19:26:20 +01:00
Jean-Sébastien Pédron aa36b43c28 Travis CI: Add configuration 2016-12-09 11:32:39 +01:00
Jean-Sébastien Pédron 44143fb2f4 Update rabbitmq-components.mk 2016-12-08 19:14:53 +01:00
Jean-Sébastien Pédron ec4a18db9a Merge branch 'stable' 2016-12-07 16:07:03 +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 e84685868f system_SUITE: Increase timetrap to 3 minutes 2016-12-02 13:03:16 +01:00
Michael Klishin 2902daa84c Update rabbitmq-components.mk 2016-11-29 20:59:42 +03:00
Jean-Sébastien Pédron 30f3233a9b Update rabbitmq-components.mk 2016-11-25 10:51:04 +01:00
Jean-Sébastien Pédron d836d9f7d7 Update rabbitmq-components.mk 2016-11-25 10:08:24 +01:00
Jean-Sébastien Pédron 0adb8ddff2 Add rabbitmq_ct_client_helpers to TEST_DEPS 2016-11-24 10:41:36 +01:00
Jean-Sébastien Pédron fc145e403c Update rabbitmq-components.mk 2016-11-23 18:06:08 +01:00
Gerhard Lazu 2c6f33f40f Update erlang.mk 2016-11-22 16:20:42 +00:00
Gerhard Lazu e455aa6a46 Update rabbitmq-components.mk 2016-11-22 16:16:45 +00:00
Jean-Sébastien Pédron e1f315db6f Update rabbitmq-components.mk 2016-09-23 11:23:11 +02:00
Jean-Sébastien Pédron 2763daf480 Update erlang.mk 2016-09-22 17:57:18 +02:00
Jean-Sébastien Pédron a8e6e56c16 rabbitmq_trust_store.app: Depend on rabbit_common 2016-09-20 12:48:11 +02:00
Jean-Sébastien Pédron 3227fa2a0e Makefile: Explicitely list all DEPS
Sync rabbitmq-components.mk with rabbitmq-common to remove automatic
DEPS handling.

[#130086871]
2016-09-20 12:47:56 +02:00
Jean-Sébastien Pédron 708dd530e4 Update erlang.mk 2016-09-20 12:46:56 +02:00
Jean-Sébastien Pédron c69c19f723 Update rabbitmq-components.mk 2016-09-15 15:48:11 +02:00
Jean-Sébastien Pédron c5c8579139 Update rabbitmq-components.mk 2016-09-02 13:22:28 +02:00
Jean-Sébastien Pédron c1937a5845 Makefile: No need to filter out rabbitmq_test from TEST_DEPS anymore
[#127356157]
2016-09-02 12:35:04 +02:00
Jean-Sébastien Pédron 112a0fa1f6 Update rabbitmq-components.mk 2016-09-02 12:03:33 +02:00
Michael Klishin 4479a44695 Update rabbitmq-components.mk 2016-07-14 15:37:37 +03:00
Michael Klishin d6852d97b4 Update rabbitmq-components.mk 2016-07-14 13:20:05 +03:00
Michael Klishin df64f250d9 Merge branch 'rabbitmq-trust-store-34' into stable 2016-06-23 16:35:49 +03:00
Michael Klishin 96a7290019 Correct a typo 2016-06-23 16:29:16 +03:00
kjnilsson 5935bedaf4 Validate the peer in a presented certificate chain 2016-06-23 13:28:33 +01:00
Michael Klishin 82cf4b8dd2 Typo 2016-06-23 13:51:23 +03:00
Michael Klishin 02f8538e09 Update README.md 2016-06-23 13:49:23 +03: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 675ff4c4c3 Move to common test
- use the private directory for the test run instead of TMPDIR
 - use dynamic TCP port allocation
 - get hostname from test configuration
 - do not use hardcoded tcp port numbers
 - don't test for the existence of the whitelist directory
 - increase test timeout
 - create test dir per test case
 - use ct groups
 - use a subdirectory of the certs directory for trust store certs

Fixes #29.
2016-06-20 18:32:38 +02:00
Michael Klishin 0a591be641 Update rabbitmq-components.mk 2016-05-29 23:21:57 +03:00
Michael Klishin a8edbf022c Update CONTRIBUTING.md, add CODE_OF_CONDUCT.md 2016-05-28 14:22:51 +03:00
Karl Nilsson be649aa087 Update rabbitmq-components.mk 2016-05-18 12:48:02 +01:00
Michael Klishin b8d6ec89c7 Update README.md 2016-05-18 13:26:29 +03:00
kjnilsson 5dfeb3fb72 README update 2016-05-18 11:09:28 +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 61c2d78c83 Bump rabbitmq-components.mk 2016-05-17 15:02:52 +03:00
kjnilsson 8b9ebb94c4 test refactoring:
- improve naming
        - remove trailing whitespace
        - add parens to make logic more explicit
        - shorten long lines
        - switch to using a proplist getter instead of lists:keyfind
2016-05-17 11:16:28 +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
Daniil Fedotov d9f9f6cca5 Updated components.mk. Added setup/teardown to tests 2016-04-14 16:07:31 +01: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 c464c7f417 Add a .gitignore 2016-03-03 15:20:46 +03: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 765000d066 Delete directory tree in test cases with a library procedure 2016-02-24 18:07:28 +01:00
Joseph Yiasemides 2c111d2d55 Test with a "whitelist" directory under TMPDIR
This reverts changes made in an earlier commit.
2016-02-24 17:05:30 +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 ac31dfbd20 Clarify which plugins the trust-store effects in the README 2016-02-16 16:57:54 +01:00
Joseph Yiasemides 20ca1a2dea Make & remove a data directory for each test case
We need somewhere to write and remove certificate files. The test set
uses a directory `data` which is relative to it's current path. It's
an improvement over what was there before becuase this is more
contained and portable between OSs.
2016-02-16 16:38:07 +01:00
Joseph Yiasemides 59de1f0598 Move behaviour declaration so that interfaces are clearer 2016-02-16 14:21:00 +01:00
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