-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client): allow to disable server cert verification on dangerous …
…feature for all http version
- Loading branch information
Showing
6 changed files
with
122 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#[cfg(feature = "rustls-ring-crypto")] | ||
pub(crate) mod rustls { | ||
use std::sync::Arc; | ||
use xitca_tls::rustls::{ | ||
self, | ||
client::danger::HandshakeSignatureValid, | ||
crypto::{verify_tls12_signature, verify_tls13_signature}, | ||
pki_types::{CertificateDer, ServerName, UnixTime}, | ||
DigitallySignedStruct, | ||
}; | ||
|
||
#[derive(Debug)] | ||
pub(crate) struct SkipServerVerification; | ||
|
||
impl SkipServerVerification { | ||
pub(crate) fn new() -> Arc<Self> { | ||
Arc::new(Self) | ||
} | ||
} | ||
|
||
impl rustls::client::danger::ServerCertVerifier for SkipServerVerification { | ||
fn verify_server_cert( | ||
&self, | ||
_end_entity: &CertificateDer<'_>, | ||
_intermediates: &[CertificateDer<'_>], | ||
_server_name: &ServerName<'_>, | ||
_ocsp: &[u8], | ||
_now: UnixTime, | ||
) -> Result<rustls::client::danger::ServerCertVerified, rustls::Error> { | ||
Ok(rustls::client::danger::ServerCertVerified::assertion()) | ||
} | ||
|
||
fn verify_tls12_signature( | ||
&self, | ||
message: &[u8], | ||
cert: &CertificateDer<'_>, | ||
dss: &DigitallySignedStruct, | ||
) -> Result<HandshakeSignatureValid, rustls::Error> { | ||
verify_tls12_signature( | ||
message, | ||
cert, | ||
dss, | ||
&rustls::crypto::ring::default_provider().signature_verification_algorithms, | ||
) | ||
} | ||
|
||
fn verify_tls13_signature( | ||
&self, | ||
message: &[u8], | ||
cert: &CertificateDer<'_>, | ||
dss: &DigitallySignedStruct, | ||
) -> Result<HandshakeSignatureValid, rustls::Error> { | ||
verify_tls13_signature( | ||
message, | ||
cert, | ||
dss, | ||
&rustls::crypto::ring::default_provider().signature_verification_algorithms, | ||
) | ||
} | ||
|
||
fn supported_verify_schemes(&self) -> Vec<rustls::SignatureScheme> { | ||
rustls::crypto::ring::default_provider() | ||
.signature_verification_algorithms | ||
.supported_schemes() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
pub(crate) mod connector; | ||
#[cfg(feature = "dangerous")] | ||
pub(crate) mod dangerous; | ||
|
||
pub type TlsStream = Box<dyn xitca_io::io::AsyncIoDyn + Send>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters