Skip to content

Commit

Permalink
Merge 50c618c into 69b96b1
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralith committed Sep 21, 2019
2 parents 69b96b1 + 50c618c commit bed5c09
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rustls/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ pub enum TLSError {

/// The peer sent an oversized record/fragment.
PeerSentOversizedRecord,

/// An incoming connection did not support any known application protocol.
NoApplicationProtocol,
}

fn join<T: fmt::Debug>(items: &[T]) -> String {
Expand Down Expand Up @@ -137,6 +140,7 @@ impl Error for TLSError {
TLSError::InvalidDNSName(_) => "invalid DNS name",
TLSError::HandshakeNotComplete => "handshake not complete",
TLSError::PeerSentOversizedRecord => "peer sent excess record size",
TLSError::NoApplicationProtocol => "peer doesn't support any known protocol",
}
}
}
Expand Down Expand Up @@ -172,7 +176,8 @@ mod tests {
TLSError::FailedToGetCurrentTime,
TLSError::InvalidDNSName("dns something".to_string()),
TLSError::HandshakeNotComplete,
TLSError::PeerSentOversizedRecord];
TLSError::PeerSentOversizedRecord,
TLSError::NoApplicationProtocol];

for err in all {
println!("{:?}:", err);
Expand Down
8 changes: 8 additions & 0 deletions rustls/src/server/hs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ impl ExtensionProcessing {
if let Some(ref selected_protocol) = sess.alpn_protocol {
debug!("Chosen ALPN protocol {:?}", selected_protocol);
self.exts.push(ServerExtension::make_alpn(&[selected_protocol]));
} else {
// For compatibility, strict ALPN validation is not employed unless targeting QUIC
#[cfg(feature = "quic")] {
if sess.common.protocol == Protocol::Quic && !our_protocols.is_empty() {
sess.common.send_fatal_alert(AlertDescription::NoApplicationProtocol);
return Err(TLSError::NoApplicationProtocol);
}
}
}
}

Expand Down

0 comments on commit bed5c09

Please sign in to comment.