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

sip/transp: add client certificate to all TLS transports #1173

Merged
merged 1 commit into from
Aug 6, 2024

Conversation

maximilianfridrich
Copy link
Contributor

@maximilianfridrich maximilianfridrich commented Jul 31, 2024

Currently, when a client certificate is added to a SIP transport, it is only added to the first matching transport in the transport list. Then, if multiple SIP transports exist (e.g if there are multiple network interfaces), the certificate might not be present in the transport when it is needed.

Now, the certificate is added to all matching transports.

This BareSIP PR tests the fix:

src/sip/transp.c Outdated
@@ -47,6 +47,12 @@ struct sip_ccert {
};


struct ccert_data {
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps add sip_ prefix to match the name of the module ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

src/sip/transp.c Outdated
static struct le *transp_apply_all(struct sip *sip, enum sip_transp tp, int af,
list_apply_h ah, void *arg)
{
struct le *le;
Copy link
Contributor

Choose a reason for hiding this comment

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

this can be moved to for-loop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

src/sip/transp.c Outdated
@@ -1401,6 +1434,27 @@ int sip_transp_add_websock(struct sip *sip, enum sip_transp tp,
}


static bool add_ccert(struct le *le, void *arg)
Copy link
Contributor

Choose a reason for hiding this comment

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

add _handler suffix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

(void)transp_apply_all(sip, SIP_TRANSP_TLS, AF_INET, add_ccert,
&cc_data);
(void)transp_apply_all(sip, SIP_TRANSP_TLS, AF_INET6, add_ccert,
&cc_data);
Copy link
Contributor

Choose a reason for hiding this comment

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

what about WSS transport ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to change the behavior as little as possible. Before this change, the sip_transp_add_ccert function did not consider WSS either and when adding the WSS transport with sip_transp_add_websock, the hash table for the certs is not even allocated.

It would probably make sense, but maybe add that support in a different PR.

Currently, when a client certificate is added to a SIP transport, it is
only added to the first matching transport in the transport list.
Then, if multiple SIP transports exist (e.g if there are multiple
network interfaces), the certificate might not be present in the
transport when it is needed.

Now, the certificate is added to all matching transports.
@alfredh
Copy link
Contributor

alfredh commented Aug 6, 2024

Please merge to main if you agree @sreimers

@sreimers sreimers merged commit ea2dfa4 into baresip:main Aug 6, 2024
36 checks passed
@maximilianfridrich maximilianfridrich deleted the transp_ccert_fix branch August 6, 2024 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants