Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better support for wildcard certificates: #737

Merged
merged 2 commits into from
Feb 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/make_certs.erl
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,14 @@ intermediateCA(Root, CA, ParentCA) ->
endusers(Root, CA, Users) ->
[enduser(Root, CA, User) || User <- Users].

enduser(Root, CA, User) ->
UsrRoot = filename:join([Root, User]),
enduser(Root, CA, {User, DirName}) ->
enduser(Root, CA, User, DirName);

enduser(Root, CA, User) ->
enduser(Root, CA, User, User).

enduser(Root, CA, User, DirName) ->
UsrRoot = filename:join([Root, DirName]),
file:make_dir(UsrRoot),
CnfFile = filename:join([UsrRoot, "req.cnf"]),
DN = #dn{commonName = User},
Expand Down
62 changes: 62 additions & 0 deletions tests/replication2_ssl.erl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ confirm() ->
make_certs:intermediateCA(CertDir, "intCA", "rootCA"),
make_certs:endusers(CertDir, "rootCA", ["site3.basho.com", "site4.basho.com"]),
make_certs:endusers(CertDir, "intCA", ["site1.basho.com", "site2.basho.com"]),
make_certs:enduser(CertDir, "intCA", "*.basho.com", "wildcard.basho.com"),

lager:info("Deploy ~p nodes", [NumNodes]),
BaseConf = [
Expand Down Expand Up @@ -188,6 +189,43 @@ confirm() ->
]}
],

SSLConfig8 = [
{riak_repl,
[
{fullsync_on_connect, false},
{fullsync_interval, disabled}
]},
{riak_core,
[
{ssl_enabled, true},
{certfile, filename:join([CertDir,
"wildcard.basho.com/cert.pem"])},
{keyfile, filename:join([CertDir,
"wildcard.basho.com/key.pem"])},
{cacertdir, filename:join([CertDir,
"wildcard.basho.com/cacerts.pem"])}
]}
],

SSLConfig9 = [
{riak_repl,
[
{fullsync_on_connect, false},
{fullsync_interval, disabled}
]},
{riak_core,
[
{ssl_enabled, true},
{peer_common_name_acl, ["*.basho.com"]},
{certfile, filename:join([CertDir,
"wildcard.basho.com/cert.pem"])},
{keyfile, filename:join([CertDir,
"wildcard.basho.com/key.pem"])},
{cacertdir, filename:join([CertDir,
"wildcard.basho.com/cacerts.pem"])}
]}
],

lager:info("===testing basic connectivity"),

[Node1, Node2] = rt:deploy_nodes(2, BaseConf, [riak_kv, riak_repl]),
Expand Down Expand Up @@ -253,6 +291,30 @@ confirm() ->
?assertEqual(ok, test_connection({Node1, merge_config(SSLConfig5, BaseConf)},
{Node2, merge_config(SSLConfig6, BaseConf)})),

%% WILDCARD CERT TESTS

lager:info("===testing wildcard certifictes on both ends"),
rt:log_to_nodes([Node1, Node2], "wildcard certificates test - both end"),
?assertEqual(ok, test_connection({Node1, merge_config(SSLConfig8, BaseConf)},
{Node2, merge_config(SSLConfig8, BaseConf)})),

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also have tests connecting wildcarded cert to non-wildcarded cert, without ACL, such as SSLConfig3 <==> SSLConfig8, and another with ACL, such as SSLConfig5 <==> SSLConfig8

lager:info("===testing wildcard certifictes on one end"),
rt:log_to_nodes([Node1, Node2], "wildcard certificates test - one end"),
?assertEqual(ok, test_connection({Node1, merge_config(SSLConfig8, BaseConf)},
{Node2, merge_config(SSLConfig3, BaseConf)})),

lager:info("===testing wildcard certifictes on one end with ACL"),
rt:log_to_nodes([Node1, Node2], "wildcard certificates test - one end with ACLs"),
?assertEqual(ok, test_connection({Node1, merge_config(SSLConfig8, BaseConf)},
{Node2, merge_config(SSLConfig5, BaseConf)})),

lager:info("===testing wildcard certifictes on both ends with ACLs"),
rt:log_to_nodes([Node1, Node2], "wildcard certificates test - both end with ACLs"),
?assertEqual(ok, test_connection({Node1, merge_config(SSLConfig9, BaseConf)},
{Node2, merge_config(SSLConfig9, BaseConf)})),

%% END WILDCARD CERT TESTS

lager:info("===testing expired certificates fail"),
rt:log_to_nodes([Node1, Node2], "expired certificates test"),
?assertMatch({fail, _}, test_connection({Node1, merge_config(SSLConfig5, BaseConf)},
Expand Down