sipsorcery-org / sipsorcery

A WebRTC, SIP and VoIP library for C# and .NET. Designed for real-time communications apps.
https://sipsorcery-org.github.io/sipsorcery
Other
1.47k stars 442 forks source link

DTLS Handshake failed #867

Closed iLikeCSharp closed 1 week ago

iLikeCSharp commented 1 year ago

Getting an error saying DTLS Handshake failed unsure what the actual error is because it doesn't really say. When it breaks it just says Org.BouncyCastle.Crypto.Tls.TlsFatalAlert: internal_error(80) at line 58

[19:39:03 DBG] Starting DLS handshake with role active.
[19:39:03 DBG] RTCPeerConnection DoDtlsHandshake started.
[19:39:03 DBG] DTLS commencing handshake as client.
[19:39:03 WRN] DTLS client received unexpected alert: fatal(2), internal_error(80).
[19:39:03 WRN] DTLS unexpected Fatal alert internal_error: internal_error(80)
[19:39:04 WRN] DTLS handshake as client failed. internal_error(80)
Org.BouncyCastle.Crypto.Tls.TlsFatalAlert: internal_error(80)
   at Org.BouncyCastle.Crypto.Tls.DtlsClientProtocol.Connect(TlsClient client, DatagramTransport transport) in /_/crypto/src/crypto/tls/DtlsClientProtocol.cs:line 58
   at SIPSorcery.Net.DtlsSrtpTransport.DoHandshakeAsClient(String& handshakeError)
[19:39:04 WRN] RTCPeerConnection DTLS handshake failed with error internal_error(80).
[19:39:04 DBG] Peer connection closed with reason dtls handshake failed.
[19:39:04 DBG] RtpIceChannel for [::]:57256 closed.
[19:39:04 DBG] RTPChannel closing, RTP receiver on port 57256. Reason: dtls handshake failed.
iLikeCSharp commented 1 year ago

Looking into it a little more, not 100% sure but I'm assuming this might be the problem. image

iLikeCSharp commented 1 year ago

Adding to the last comment, at SIPSorcery.Net.DtlsUtils.LoadSignerCredentials there is a check for supportedSignatureAlgorithms to see if it contains SignatureAlgorithm.rsa(1) but supportedSignatureAlgorithms only contains SignatureAlgorithm.dsa (2) and SignatureAlgorithm.ecdsa (3) causing it to return null which results in a EmptyChain

sipsorcery commented 1 week ago

Should be fixed by #1201.