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

Only refuse same common name if CommonName isn’t a wildcard CN. #713

Merged
merged 1 commit into from
Feb 25, 2015
Merged
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
8 changes: 7 additions & 1 deletion src/riak_core_ssl_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ load_cert(Cert) ->
Type == 'Certificate', Cipher == 'not_encrypted']
end.

%% Reject another node whose common name is the same as ours unless it's a wildcard
invalid_cn_pair([$* | _], _) ->
false;
invalid_cn_pair(LeftCN, RightCN) ->
string:to_lower(LeftCN) == string:to_lower(RightCN).

%% Custom SSL verification function for checking common names against the
%% whitelist.
verify_ssl(_, {bad_cert, _} = Reason, _) ->
Expand All @@ -186,7 +192,7 @@ verify_ssl(_, valid_peer, undefined) ->
{fail, bad_local_common_name};
verify_ssl(Cert, valid_peer, {App, MyCommonName}) ->
CommonName = get_common_name(Cert),
case string:to_lower(CommonName) == string:to_lower(MyCommonName) of
case invalid_cn_pair(CommonName, MyCommonName) of
true ->
lager:error("Peer certificate's common name matches local "
"certificate's common name: ~p", [CommonName]),
Expand Down