use std::{fmt::Debug, future::Future};
#[derive(Debug, Clone)]
pub enum ContentEncoding {
PEM,
DER,
}
pub trait IdentityNativeExt {
fn from_pkcs12(bundle: &[u8], password: Option<String>) -> Self;
fn from_pkcs12_file(
file: &str,
password: Option<String>,
) -> impl Future<Output = std::io::Result<Self>>
where
Self: Sized;
}
pub trait IdentityExt {
fn from_pkcs8(cert: &[u8], key: &[u8], encoding: ContentEncoding) -> Self;
fn from_pkcs8_file(
cert: &str,
key: &str,
encoding: ContentEncoding,
) -> impl Future<Output = std::io::Result<Self>>
where
Self: Sized;
}
pub trait Identity {
fn cert(&self) -> &Vec<u8>;
fn key(&self) -> &Option<Vec<u8>>;
fn encoding(&self) -> &Option<ContentEncoding>;
}
pub trait CertificateExt {
fn from_slice(data: &[u8], encoding: ContentEncoding) -> Self;
fn from_file(
file: &str,
encoding: ContentEncoding,
) -> impl Future<Output = std::io::Result<Self>>
where
Self: Sized;
}
pub trait Certificate {
fn as_bytes(&self) -> &Vec<u8>;
}