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

Verify peer cert fingerprint #22

Merged
merged 2 commits into from
Nov 28, 2023
Merged

Verify peer cert fingerprint #22

merged 2 commits into from
Nov 28, 2023

Conversation

mickel8
Copy link
Member

@mickel8 mickel8 commented Nov 25, 2023

When peer cert fingerprint does not match the one provided in SDP we will move to the failed state and stop the PeerConnection process for now.

The question is if we should stick to the permanent restart strategy in a GenServer as it makes Supervisor always restart our GenServer, even when exited with :normal, :shutdown or {:shutdown, term} reasons.

For now, I left this to be configured by a user using Supervisor.child_spec.

Copy link

codecov bot commented Nov 25, 2023

Codecov Report

Merging #22 (66e9c67) into master (6154a3b) will decrease coverage by 0.56%.
The diff coverage is 82.35%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #22      +/-   ##
==========================================
- Coverage   84.40%   83.85%   -0.56%     
==========================================
  Files          10       10              
  Lines         449      483      +34     
==========================================
+ Hits          379      405      +26     
- Misses         70       78       +8     
Files Coverage Δ
lib/ex_webrtc/dtls_transport.ex 84.14% <85.71%> (-2.87%) ⬇️
lib/ex_webrtc/peer_connection.ex 79.78% <76.92%> (+<0.01%) ⬆️
lib/ex_webrtc/sdp_utils.ex 85.86% <83.33%> (-0.90%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6154a3b...66e9c67. Read the comment docs.

@mickel8 mickel8 force-pushed the verify-fingerprint branch 5 times, most recently from 0ff209d to 4c25e71 Compare November 27, 2023 09:44
Base automatically changed from conn-state to master November 27, 2023 09:57
@mickel8 mickel8 force-pushed the verify-fingerprint branch 6 times, most recently from 770cf3b to 788fb37 Compare November 27, 2023 15:24
@mickel8 mickel8 marked this pull request as ready for review November 27, 2023 15:29
@mickel8 mickel8 requested a review from LVala November 27, 2023 15:29
state = setup_srtp(state, remote_keying_material, profile)
update_dtls_state(state, :connected)
else
Logger.debug("Non-matching peer cert fingerprint.")
Copy link
Member

Choose a reason for hiding this comment

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

I think this is probably a rare error, isn't it? Maybe Logger.debug is too lax for the severity? State change to :failed doesn't really tell much about the reason, so it's gonna be easy to miss.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so. PeerConnection state failed means that either ICE failed or DTLS failed. Because user has access to ICE state it can easily know that the problem is failing DTLS.

I would say that all our logs should be on debug as we create a library. It's API role to give user sufficient information on what's going on

@@ -408,7 +415,7 @@ defmodule ExWebRTC.PeerConnection do
dtls =
if type == :answer do
{:setup, setup} = ExSDP.Media.get_attribute(hd(sdp.media), :setup)
:ok = DTLSTransport.start_dtls(state.dtls_transport, setup)
:ok = DTLSTransport.start_dtls(state.dtls_transport, setup, state.peer_fingerprint)
Copy link
Member

Choose a reason for hiding this comment

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

Isn't it an issue that the fingerprint here might be nil as far as I understand?

Copy link
Member Author

Choose a reason for hiding this comment

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

This should never happen as we can't set SDP answer before receiving SDP offer. When we receive SDP offer we save peer_fingerprint in the state

Copy link
Member

Choose a reason for hiding this comment

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

right

@LVala LVala self-requested a review November 28, 2023 09:59
@mickel8 mickel8 merged commit 16043e7 into master Nov 28, 2023
4 checks passed
@mickel8 mickel8 deleted the verify-fingerprint branch November 28, 2023 10:00
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.

2 participants