mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-20 09:03:28 +00:00
simplify rustls::ClientConfig in tls.probe()
This commit is contained in:
parent
bda9bc94e2
commit
04e2311920
1 changed files with 10 additions and 16 deletions
|
|
@ -10,13 +10,12 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use locales::t;
|
use locales::t;
|
||||||
use modals::Modals;
|
use modals::Modals;
|
||||||
|
use ota::OwnedTrustAnchor;
|
||||||
use rkyv::{
|
use rkyv::{
|
||||||
de::deserializers::AllocDeserializer,
|
de::deserializers::AllocDeserializer,
|
||||||
ser::{serializers::WriteSerializer, Serializer},
|
ser::{serializers::WriteSerializer, Serializer},
|
||||||
Deserialize,
|
Deserialize,
|
||||||
};
|
};
|
||||||
use ota::OwnedTrustAnchor;
|
|
||||||
use rustls::crypto::ring;
|
|
||||||
use rustls::pki_types::{CertificateDer, TrustAnchor};
|
use rustls::pki_types::{CertificateDer, TrustAnchor};
|
||||||
use rustls::{ClientConfig, ClientConnection, RootCertStore};
|
use rustls::{ClientConfig, ClientConnection, RootCertStore};
|
||||||
use x509_parser::prelude::{parse_x509_certificate, FromDer, X509Certificate};
|
use x509_parser::prelude::{parse_x509_certificate, FromDer, X509Certificate};
|
||||||
|
|
@ -304,19 +303,14 @@ impl Tls {
|
||||||
log::info!("starting TLS probe");
|
log::info!("starting TLS probe");
|
||||||
match host.to_owned().try_into() {
|
match host.to_owned().try_into() {
|
||||||
Ok(server_name) => {
|
Ok(server_name) => {
|
||||||
match rustls::ClientConfig::builder_with_provider(Arc::new(ring::default_provider()))
|
// Stifle the default rustls certificate verification's complaint about an
|
||||||
.with_safe_default_protocol_versions()
|
// unknown/untrusted CA root certificate so that we get to see the certificate chain
|
||||||
{
|
let config = rustls::ClientConfig::builder()
|
||||||
Ok(config_builder) => {
|
.dangerous()
|
||||||
// Stifle the default rustls certificate verification's complaint about an
|
.with_custom_certificate_verifier(Arc::new(danger::StifledCertificateVerification::new()))
|
||||||
// unknown/untrusted CA root certificate so that we get to see the certificate chain
|
.with_no_client_auth();
|
||||||
let config = config_builder
|
match rustls::ClientConnection::new(Arc::new(config), server_name) {
|
||||||
.dangerous()
|
Ok(mut conn) => {
|
||||||
.with_custom_certificate_verifier(Arc::new(
|
|
||||||
danger::StifledCertificateVerification::new(),
|
|
||||||
))
|
|
||||||
.with_no_client_auth();
|
|
||||||
let mut conn = rustls::ClientConnection::new(Arc::new(config), server_name).unwrap();
|
|
||||||
log::info!("connect TCPstream to {}", host);
|
log::info!("connect TCPstream to {}", host);
|
||||||
match TcpStream::connect((host, 443)) {
|
match TcpStream::connect((host, 443)) {
|
||||||
Ok(mut sock) => match conn.complete_io(&mut sock) {
|
Ok(mut sock) => match conn.complete_io(&mut sock) {
|
||||||
|
|
@ -336,7 +330,7 @@ impl Tls {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::warn!("{e}");
|
log::warn!("failed to create ClientConnection: {e}");
|
||||||
Err(Error::from(ErrorKind::InvalidInput))
|
Err(Error::from(ErrorKind::InvalidInput))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue