mirror of
https://github.com/arampoire/nut-rs.git
synced 2025-12-01 00:30:23 -05:00
Release 0.5.0
Rename to rups
This commit is contained in:
parent
539d11848e
commit
feef67255f
21 changed files with 51 additions and 47 deletions
30
rups/src/ssl/mod.rs
Normal file
30
rups/src/ssl/mod.rs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
use crate::Config;
|
||||
|
||||
/// The certificate validation mechanism that allows any certificate.
|
||||
pub struct InsecureCertificateValidator {
|
||||
debug: bool,
|
||||
}
|
||||
|
||||
impl InsecureCertificateValidator {
|
||||
/// Initialize a new instance.
|
||||
pub fn new(config: &Config) -> Self {
|
||||
InsecureCertificateValidator {
|
||||
debug: config.debug,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl rustls::ServerCertVerifier for InsecureCertificateValidator {
|
||||
fn verify_server_cert(
|
||||
&self,
|
||||
_roots: &rustls::RootCertStore,
|
||||
_presented_certs: &[rustls::Certificate],
|
||||
_dns_name: webpki::DNSNameRef<'_>,
|
||||
_ocsp: &[u8],
|
||||
) -> Result<rustls::ServerCertVerified, rustls::TLSError> {
|
||||
if self.debug {
|
||||
eprintln!("DEBUG <- (!) Certificate received, but not verified");
|
||||
}
|
||||
Ok(rustls::ServerCertVerified::assertion())
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue