mirror of
https://github.com/instant-labs/instant-acme.git
synced 2025-02-16 13:22:04 +00:00
Make hyper-rustls dependency optional
This commit is contained in:
parent
ae2b5aea98
commit
1aa770c2de
11
Cargo.toml
11
Cargo.toml
@ -11,10 +11,13 @@ keywords = ["letsencrypt", "acme"]
|
||||
categories = ["web-programming", "api-bindings"]
|
||||
rust-version = "1.60.0"
|
||||
|
||||
[features]
|
||||
default = ["hyper-rustls"]
|
||||
|
||||
[dependencies]
|
||||
base64 = "0.21.0"
|
||||
hyper = { version = "0.14.18", features = ["client", "http1", "http2"] }
|
||||
hyper-rustls = { version = "0.24", default-features = false, features = ["http1", "http2", "native-tokio", "tls12"] }
|
||||
hyper-rustls = { version = "0.24", default-features = false, features = ["http1", "http2", "native-tokio", "tls12"], optional = true }
|
||||
ring = { version = "0.16.20", features = ["std"] }
|
||||
serde = { version = "1.0.104", features = ["derive"] }
|
||||
serde_json = "1.0.78"
|
||||
@ -24,6 +27,10 @@ thiserror = "1.0.30"
|
||||
anyhow = "1.0.66"
|
||||
clap = { version = "4.0.29", features = ["derive"] }
|
||||
rcgen = "0.10.0"
|
||||
tokio = { version = "1.22.0", features = ["rt", "macros", "rt-multi-thread"] }
|
||||
tokio = { version = "1.22.0", features = ["macros", "rt", "rt-multi-thread", "time"] }
|
||||
tracing = "0.1.37"
|
||||
tracing-subscriber = "0.3.16"
|
||||
|
||||
[[example]]
|
||||
name = "provision"
|
||||
required-features = ["hyper-rustls"]
|
||||
|
@ -8,7 +8,9 @@ use std::fmt;
|
||||
use std::sync::Arc;
|
||||
|
||||
use base64::prelude::{Engine, BASE64_URL_SAFE_NO_PAD};
|
||||
use hyper::client::{HttpConnector, ResponseFuture};
|
||||
#[cfg(feature = "hyper-rustls")]
|
||||
use hyper::client::HttpConnector;
|
||||
use hyper::client::ResponseFuture;
|
||||
use hyper::header::{CONTENT_TYPE, LOCATION};
|
||||
use hyper::{Body, Method, Request, Response};
|
||||
use ring::digest::{digest, SHA256};
|
||||
@ -198,6 +200,7 @@ impl Account {
|
||||
/// Restore an existing account from the given credentials
|
||||
///
|
||||
/// The [`AccountCredentials`] type is opaque, but supports deserialization.
|
||||
#[cfg(feature = "hyper-rustls")]
|
||||
pub fn from_credentials(credentials: AccountCredentials<'_>) -> Result<Self, Error> {
|
||||
Ok(Self {
|
||||
inner: Arc::new(AccountInner::from_credentials(
|
||||
@ -220,6 +223,7 @@ impl Account {
|
||||
}
|
||||
|
||||
/// Create a new account on the `server_url` with the information in [`NewAccount`]
|
||||
#[cfg(feature = "hyper-rustls")]
|
||||
pub async fn create(
|
||||
account: &NewAccount<'_>,
|
||||
server_url: &str,
|
||||
@ -589,14 +593,17 @@ fn nonce_from_response(rsp: &Response<Body>) -> Option<String> {
|
||||
.and_then(|hv| String::from_utf8(hv.as_ref().to_vec()).ok())
|
||||
}
|
||||
|
||||
#[cfg(feature = "hyper-rustls")]
|
||||
struct DefaultClient(hyper::Client<hyper_rustls::HttpsConnector<HttpConnector>>);
|
||||
|
||||
#[cfg(feature = "hyper-rustls")]
|
||||
impl HttpClient for DefaultClient {
|
||||
fn request(&self, req: Request<Body>) -> ResponseFuture {
|
||||
self.0.request(req)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "hyper-rustls")]
|
||||
impl Default for DefaultClient {
|
||||
fn default() -> Self {
|
||||
Self(
|
||||
|
Loading…
Reference in New Issue
Block a user