refactor: rename allow_all->verifier, AllowAll->InternalCertVerifier

This commit is contained in:
DarkCat09 2024-08-28 17:19:18 +04:00
parent 73addc33ca
commit 0e8d023880
Signed by: DarkCat09
GPG key ID: BD3CE9B65916CD82
3 changed files with 10 additions and 10 deletions

View file

@ -1,7 +1,7 @@
//! Everything related to TLS certs verification //! Everything related to TLS certs verification
pub mod allow_all;
pub mod fingerprint; pub mod fingerprint;
pub mod verifier;
#[cfg(feature = "file-sscv")] #[cfg(feature = "file-sscv")]
pub mod file_sscv; pub mod file_sscv;

View file

@ -11,19 +11,19 @@ use tokio_rustls::rustls::{
/// Custom verifier for Rustls accepting any TLS certificate /// Custom verifier for Rustls accepting any TLS certificate
#[derive(Debug)] #[derive(Debug)]
pub struct AllowAllCertVerifier(Arc<CryptoProvider>); pub struct InternalCertVerifier(Arc<CryptoProvider>);
impl Default for AllowAllCertVerifier { impl Default for InternalCertVerifier {
/// Same as [`AllowAllCertVerifier::new()`]. /// Same as [`AllowAllCertVerifier::new()`].
fn default() -> Self { fn default() -> Self {
Self::new() Self::new()
} }
} }
impl AllowAllCertVerifier { impl InternalCertVerifier {
/// Constructor for this verifier. /// Constructor for this verifier.
pub fn new() -> Self { pub fn new() -> Self {
AllowAllCertVerifier( InternalCertVerifier(
CryptoProvider::get_default() CryptoProvider::get_default()
.cloned() .cloned()
.unwrap_or_else(|| Arc::new(rustls::crypto::ring::default_provider())), .unwrap_or_else(|| Arc::new(rustls::crypto::ring::default_provider())),
@ -31,14 +31,14 @@ impl AllowAllCertVerifier {
} }
} }
impl From<Arc<CryptoProvider>> for AllowAllCertVerifier { impl From<Arc<CryptoProvider>> for InternalCertVerifier {
#[inline] #[inline]
fn from(value: Arc<CryptoProvider>) -> Self { fn from(value: Arc<CryptoProvider>) -> Self {
AllowAllCertVerifier(value) InternalCertVerifier(value)
} }
} }
impl ServerCertVerifier for AllowAllCertVerifier { impl ServerCertVerifier for InternalCertVerifier {
#[inline] #[inline]
fn verify_server_cert( fn verify_server_cert(
&self, &self,

View file

@ -3,7 +3,7 @@
use std::sync::Arc; use std::sync::Arc;
use crate::{ use crate::{
certs::{allow_all::AllowAllCertVerifier, SelfsignedCertVerifier}, certs::{verifier::InternalCertVerifier, SelfsignedCertVerifier},
Client, Client,
}; };
@ -56,7 +56,7 @@ impl ClientBuilder {
}) })
.unwrap() .unwrap()
.dangerous() .dangerous()
.with_custom_certificate_verifier(Arc::new(AllowAllCertVerifier::from(provider))); .with_custom_certificate_verifier(Arc::new(InternalCertVerifier::from(provider)));
// TODO // TODO
let tls_config = tls_config.with_no_client_auth(); let tls_config = tls_config.with_no_client_auth();