mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-21 13:08:42 +00:00

- ci: Check feat powerset of leon & binstalk-downloader in `ci.yml` - fix leon feature `cli`: Enable dep `miette` in feature `cli` - fix binstalk-downloader when default feature is disabled and no other tls related feature is enabled (breaking change due to replace of `tls::Version` with newtype `TLSVersion`). Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
32 lines
940 B
Rust
32 lines
940 B
Rust
#[cfg(feature = "__tls")]
|
|
use reqwest::tls;
|
|
|
|
use super::Error;
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub struct Certificate(#[cfg(feature = "__tls")] pub(super) tls::Certificate);
|
|
|
|
#[cfg_attr(not(feature = "__tls"), allow(unused_variables))]
|
|
impl Certificate {
|
|
/// Create a Certificate from a binary DER encoded certificate
|
|
pub fn from_der(der: impl AsRef<[u8]>) -> Result<Self, Error> {
|
|
#[cfg(not(feature = "__tls"))]
|
|
return Ok(Self());
|
|
|
|
#[cfg(feature = "__tls")]
|
|
tls::Certificate::from_der(der.as_ref())
|
|
.map(Self)
|
|
.map_err(Error::from)
|
|
}
|
|
|
|
/// Create a Certificate from a PEM encoded certificate
|
|
pub fn from_pem(pem: impl AsRef<[u8]>) -> Result<Self, Error> {
|
|
#[cfg(not(feature = "__tls"))]
|
|
return Ok(Self());
|
|
|
|
#[cfg(feature = "__tls")]
|
|
tls::Certificate::from_pem(pem.as_ref())
|
|
.map(Self)
|
|
.map_err(Error::from)
|
|
}
|
|
}
|