1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-08-09 04:22:45 +03:00

Use rustls-platform-verifier for cert validation

This simplifies by removing the mutually exclusive `native-roots` and
`webpki-roots` features with something that is suitable for all
platforms.
This commit is contained in:
Quentin Gliech
2024-03-06 11:23:42 +01:00
parent 58d91f91d2
commit 6eb6209bd8
25 changed files with 173 additions and 258 deletions

View File

@@ -14,8 +14,8 @@
use axum::body::Full;
use mas_http::{
make_traced_connector, BodyToBytesResponseLayer, Client, ClientInitError, ClientLayer,
ClientService, HttpService, TracedClient, TracedConnector,
make_traced_connector, BodyToBytesResponseLayer, Client, ClientLayer, ClientService,
HttpService, TracedClient, TracedConnector,
};
use tower::{
util::{MapErrLayer, MapRequestLayer},
@@ -28,18 +28,20 @@ pub struct HttpClientFactory {
client_layer: ClientLayer,
}
impl Default for HttpClientFactory {
fn default() -> Self {
Self::new()
}
}
impl HttpClientFactory {
/// Constructs a new HTTP client factory
///
/// # Errors
///
/// Returns an error if the client factory failed to initialise, which can
/// happen when it fails to load the system's CA certificates.
pub async fn new() -> Result<Self, ClientInitError> {
Ok(Self {
traced_connector: make_traced_connector().await?,
#[must_use]
pub fn new() -> Self {
Self {
traced_connector: make_traced_connector(),
client_layer: ClientLayer::new(),
})
}
}
/// Constructs a new HTTP client