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

Add support for chained certificates #3134

Merged
merged 3 commits into from
Nov 8, 2024

Conversation

nelsonkopliku
Copy link
Member

Description

Adds support for chained certificates in SUMA integration

See #2596 and https://elixirforum.com/t/using-client-certificates-from-a-string-with-httposion/8631/7

Supersedes #3131 which was targeting last release tag for testing purposes.

Copy link
Member

@stefanotorresi stefanotorresi left a comment

Choose a reason for hiding this comment

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

Excellent!

Comment on lines +15 to +30
describe "Http executor certificate handling" do
test "should support chained certificates" do
scenarios = [
%{cert: "one_entry_chain.pem", expected_entries: 1},
%{cert: "two_entries_chain.pem", expected_entries: 2},
%{cert: "three_entries_chain.pem", expected_entries: 3}
]

for %{cert: cert, expected_entries: expected_entries} <- scenarios do
assert cert
|> load_certificate_content()
|> HttpExecutor.get_cert_der()
|> length() == expected_entries
end
end
end
Copy link
Member

Choose a reason for hiding this comment

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

I'm only left longing for more comprehensive testing, e.g. checking that the CA chain can actually verify a server certificate previously signed with it, but I realize this is a lot of work, and at the moment time is of the essence.

Maybe @gagandeepb could pick this up at a later stage, since he mentioned he wanted to do some testing in the context of our TLS usage in general.

Copy link
Member Author

Choose a reason for hiding this comment

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

Definitely something to look into. Thanks for the pointer.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with you @stefanotorresi but at the same time this is also something on which we need a lot of feedback by the users 👍

Copy link
Contributor

@gagandeepb gagandeepb left a comment

Choose a reason for hiding this comment

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

LGTM.

Comment on lines 223 to 225
defp split_type_and_entry(asn1_entry) do
asn1_type = elem(asn1_entry, 0)
{asn1_type, asn1_entry}
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: this function could be just declarative:

Suggested change
defp split_type_and_entry(asn1_entry) do
asn1_type = elem(asn1_entry, 0)
{asn1_type, asn1_entry}
defp split_type_and_entry({asn1_type, _} = asn1_entry) do
{asn1_type, asn1_entry}

Copy link
Member Author

@nelsonkopliku nelsonkopliku Nov 8, 2024

Choose a reason for hiding this comment

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

At the end I removed the function altogether and moved it in the mapping pipe 9569dde

Just for reference, the pem decoded entry seems to be a 4 element tuple rather than a 2 element tuple https://www.erlang.org/doc/apps/public_key/public_key.html#t:pem_entry/0.

Hope it remains like this 😄

Copy link
Contributor

@dottorblaster dottorblaster left a comment

Choose a reason for hiding this comment

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

Just a couple nitpicks but LGTM :shipit:

@nelsonkopliku nelsonkopliku merged commit f829c6f into main Nov 8, 2024
30 checks passed
@nelsonkopliku nelsonkopliku deleted the support-chained-certificates branch November 8, 2024 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

4 participants