diff --git a/rtc-dtls/src/alert/mod.rs b/rtc-dtls/src/alert/mod.rs index 4ebbef0..602e7e8 100644 --- a/rtc-dtls/src/alert/mod.rs +++ b/rtc-dtls/src/alert/mod.rs @@ -62,6 +62,7 @@ pub(crate) enum AlertDescription { UserCanceled = 90, NoRenegotiation = 100, UnsupportedExtension = 110, + UnknownPskIdentity = 115, Invalid, } @@ -93,6 +94,7 @@ impl fmt::Display for AlertDescription { AlertDescription::UserCanceled => write!(f, "UserCanceled"), AlertDescription::NoRenegotiation => write!(f, "NoRenegotiation"), AlertDescription::UnsupportedExtension => write!(f, "UnsupportedExtension"), + AlertDescription::UnknownPskIdentity => write!(f, "UnknownPskIdentity"), _ => write!(f, "Invalid alert description"), } } @@ -126,6 +128,7 @@ impl From for AlertDescription { 90 => AlertDescription::UserCanceled, 100 => AlertDescription::NoRenegotiation, 110 => AlertDescription::UnsupportedExtension, + 115 => AlertDescription::UnknownPskIdentity, _ => AlertDescription::Invalid, } } diff --git a/rtc-dtls/src/conn/mod.rs b/rtc-dtls/src/conn/mod.rs index 87c86bf..3c09536 100644 --- a/rtc-dtls/src/conn/mod.rs +++ b/rtc-dtls/src/conn/mod.rs @@ -595,7 +595,20 @@ impl DTLSConn { Ok(pkt) => pkt, Err(err) => { debug!("{}: decrypt failed: {}", srv_cli_str(self.is_client), err); - return (false, None, None); + + // If we get an error for PSK we need to return an error. + if cipher_suite.is_psk() { + return ( + false, + Some(Alert { + alert_level: AlertLevel::Fatal, + alert_description: AlertDescription::UnknownPskIdentity, + }), + None, + ); + } else { + return (false, None, None); + } } }; } diff --git a/rtc-dtls/src/extension/renegotiation_info.rs b/rtc-dtls/src/extension/renegotiation_info.rs index ae56a45..48b1fcd 100644 --- a/rtc-dtls/src/extension/renegotiation_info.rs +++ b/rtc-dtls/src/extension/renegotiation_info.rs @@ -7,7 +7,7 @@ use shared::error::Error; const RENEGOTIATION_INFO_HEADER_SIZE: usize = 5; /// RenegotiationInfo allows a Client/Server to -/// communicate their renegotation support +/// communicate their renegotiation support /// https://tools.ietf.org/html/rfc5746 #[derive(Clone, Debug, PartialEq, Eq)] pub struct ExtensionRenegotiationInfo {