mirror of
https://github.com/seemueller-io/hyper-custom-cert.git
synced 2025-09-08 22:46:45 +00:00
- Downgrade edition
from 2024 to 2021 in Cargo.toml files for compatibility.
- Fix nested `if let` statements to improve readability and correctness. - Reorganize imports for consistency and structure.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "example"
|
name = "example"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2021"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# No-op features used only by the example to allow conditional compilation in docs/examples.
|
# No-op features used only by the example to allow conditional compilation in docs/examples.
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
use axum::{
|
use axum::{
|
||||||
Router,
|
|
||||||
extract::{Path, Query},
|
extract::{Path, Query},
|
||||||
response::Json,
|
response::Json,
|
||||||
routing::{delete, get, post, put},
|
routing::{delete, get, post, put},
|
||||||
|
Router,
|
||||||
};
|
};
|
||||||
use hyper_custom_cert::HttpClient;
|
use hyper_custom_cert::HttpClient;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::{Value, json};
|
use serde_json::{json, Value};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "hyper-custom-cert"
|
name = "hyper-custom-cert"
|
||||||
version = "0.3.6"
|
version = "0.3.6"
|
||||||
edition = "2024"
|
edition = "2021"
|
||||||
description = "A small, ergonomic HTTP client wrapper around hyper with optional support for custom Root CAs and a dev-only insecure mode for self-signed certificates."
|
description = "A small, ergonomic HTTP client wrapper around hyper with optional support for custom Root CAs and a dev-only insecure mode for self-signed certificates."
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
repository = "https://github.com/seemueller-io/hyper-custom-cert"
|
repository = "https://github.com/seemueller-io/hyper-custom-cert"
|
||||||
|
@@ -37,7 +37,7 @@ use std::time::Duration;
|
|||||||
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use http_body_util::BodyExt;
|
use http_body_util::BodyExt;
|
||||||
use hyper::{Method, Request, Response, StatusCode, Uri, body::Incoming};
|
use hyper::{body::Incoming, Method, Request, Response, StatusCode, Uri};
|
||||||
use hyper_util::client::legacy::Client;
|
use hyper_util::client::legacy::Client;
|
||||||
use hyper_util::rt::TokioExecutor;
|
use hyper_util::rt::TokioExecutor;
|
||||||
|
|
||||||
@@ -367,11 +367,11 @@ impl HttpClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add any request-specific headers from options
|
// Add any request-specific headers from options
|
||||||
if let Some(options) = &options
|
if let Some(options) = &options {
|
||||||
&& let Some(headers) = &options.headers
|
if let Some(headers) = &options.headers {
|
||||||
{
|
for (key, value) in headers {
|
||||||
for (key, value) in headers {
|
req = req.header(key, value);
|
||||||
req = req.header(key, value);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -503,11 +503,11 @@ impl HttpClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add any request-specific headers from options
|
// Add any request-specific headers from options
|
||||||
if let Some(options) = &options
|
if let Some(options) = &options {
|
||||||
&& let Some(headers) = &options.headers
|
if let Some(headers) = &options.headers {
|
||||||
{
|
for (key, value) in headers {
|
||||||
for (key, value) in headers {
|
req = req.header(key, value);
|
||||||
req = req.header(key, value);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -654,10 +654,10 @@ impl HttpClient {
|
|||||||
// and NEVER in production environments. This creates a vulnerability to
|
// and NEVER in production environments. This creates a vulnerability to
|
||||||
// man-in-the-middle attacks and is extremely dangerous.
|
// man-in-the-middle attacks and is extremely dangerous.
|
||||||
|
|
||||||
use rustls::DigitallySignedStruct;
|
|
||||||
use rustls::SignatureScheme;
|
|
||||||
use rustls::client::danger::{HandshakeSignatureValid, ServerCertVerified};
|
use rustls::client::danger::{HandshakeSignatureValid, ServerCertVerified};
|
||||||
use rustls::pki_types::UnixTime;
|
use rustls::pki_types::UnixTime;
|
||||||
|
use rustls::DigitallySignedStruct;
|
||||||
|
use rustls::SignatureScheme;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
// Override the certificate verifier with a no-op verifier that accepts all certificates
|
// Override the certificate verifier with a no-op verifier that accepts all certificates
|
||||||
@@ -731,12 +731,12 @@ impl HttpClient {
|
|||||||
#[cfg(feature = "rustls")]
|
#[cfg(feature = "rustls")]
|
||||||
let rustls_config = if let Some(ref pins) = self.pinned_cert_sha256 {
|
let rustls_config = if let Some(ref pins) = self.pinned_cert_sha256 {
|
||||||
// Implement certificate pinning by creating a custom certificate verifier
|
// Implement certificate pinning by creating a custom certificate verifier
|
||||||
use rustls::DigitallySignedStruct;
|
|
||||||
use rustls::SignatureScheme;
|
|
||||||
use rustls::client::danger::{
|
use rustls::client::danger::{
|
||||||
HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier,
|
HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier,
|
||||||
};
|
};
|
||||||
use rustls::pki_types::{CertificateDer, ServerName, UnixTime};
|
use rustls::pki_types::{CertificateDer, ServerName, UnixTime};
|
||||||
|
use rustls::DigitallySignedStruct;
|
||||||
|
use rustls::SignatureScheme;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
// Create a custom certificate verifier that checks certificate pins
|
// Create a custom certificate verifier that checks certificate pins
|
||||||
|
Reference in New Issue
Block a user