tokio-xmpp: Remove an unwrap() in DNS name parsing

This commit is contained in:
Emmanuel Gil Peyrot 2021-12-01 17:30:20 +01:00 committed by Link Mauve
commit edba9c9f5d
2 changed files with 15 additions and 1 deletions

View file

@ -42,7 +42,7 @@ async fn get_tls_stream<S: AsyncRead + AsyncWrite + Unpin>(
xmpp_stream: XMPPStream<S>,
) -> Result<TlsStream<S>, Error> {
let domain = &xmpp_stream.jid.clone().domain();
let domain = ServerName::try_from(domain.as_str()).unwrap();
let domain = ServerName::try_from(domain.as_str())?;
let stream = xmpp_stream.into_inner();
let mut root_store = RootCertStore::empty();
root_store.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|ta| {