macro_rules! impl_display {
($ty:ty) => {
impl std::fmt::Display for $ty {
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
Ok(())
}
}
};
}
macro_rules! impl_deref {
($from:ty => $to:ty) => {
impl std::ops::Deref for $from {
type Target = $to;
fn deref(&self) -> &$to {
panic!("Not implemented");
}
}
impl std::ops::DerefMut for $from {
fn deref_mut(&mut self) -> &mut $to {
panic!("Not implemented");
}
}
};
}
pub mod ssl {
use super::error::ErrorStack;
use super::x509::verify::X509VerifyParamRef;
use super::x509::{X509VerifyResult, X509};
pub struct AlpnError;
impl AlpnError {
pub const ALERT_FATAL: AlpnError = Self {};
pub const NOACK: AlpnError = Self {};
}
pub struct ConnectConfiguration;
impl_deref! {ConnectConfiguration => SslRef}
impl ConnectConfiguration {
pub fn set_use_server_name_indication(&mut self, _use_sni: bool) {
panic!("Not implemented");
}
pub fn set_verify_hostname(&mut self, _verify_hostname: bool) {
panic!("Not implemented");
}
pub fn into_ssl(self, _domain: &str) -> Result<Ssl, ErrorStack> {
panic!("Not implemented");
}
pub fn set_verify(&mut self, _mode: SslVerifyMode) {
panic!("Not implemented");
}
pub fn set_alpn_protos(&mut self, _protocols: &[u8]) -> Result<(), ErrorStack> {
panic!("Not implemented");
}
pub fn param_mut(&mut self) -> &mut X509VerifyParamRef {
panic!("Not implemented");
}
}
#[derive(Debug)]
pub struct Error;
impl_display!(Error);
impl Error {
pub fn code(&self) -> ErrorCode {
panic!("Not implemented");
}
}
#[derive(PartialEq)]
pub struct ErrorCode(i32);
impl ErrorCode {
pub const SSL: ErrorCode = Self(0);
}
pub struct NameType;
impl NameType {
pub const HOST_NAME: NameType = Self {};
}
pub struct Ssl;
impl Ssl {
pub fn new(_ctx: &SslContextRef) -> Result<Ssl, ErrorStack> {
panic!("Not implemented");
}
}
impl_deref! {Ssl => SslRef}
pub struct SslAcceptor;
impl SslAcceptor {
pub fn mozilla_intermediate_v5(
_method: SslMethod,
) -> Result<SslAcceptorBuilder, ErrorStack> {
panic!("Not implemented");
}
}
pub struct SslAcceptorBuilder;
impl SslAcceptorBuilder {
pub fn build(self) -> SslAcceptor {
panic!("Not implemented");
}
pub fn set_alpn_select_callback<F>(&mut self, _callback: F)
where
F: for<'a> Fn(&mut SslRef, &'a [u8]) -> Result<&'a [u8], AlpnError>
+ 'static
+ Sync
+ Send,
{
panic!("Not implemented");
}
pub fn set_certificate_chain_file<P: AsRef<std::path::Path>>(
&mut self,
_file: P,
) -> Result<(), ErrorStack> {
panic!("Not implemented");
}
pub fn set_private_key_file<P: AsRef<std::path::Path>>(
&mut self,
_file: P,
_file_type: SslFiletype,
) -> Result<(), ErrorStack> {
panic!("Not implemented");
}
pub fn set_max_proto_version(
&mut self,
_version: Option<SslVersion>,
) -> Result<(), ErrorStack> {
panic!("Not implemented");
}
}
pub struct SslCipherRef;
impl SslCipherRef {
pub fn name(&self) -> &'static str {
panic!("Not implemented");
}
}
pub struct SslConnector;
impl SslConnector {
pub fn builder(_method: SslMethod) -> Result<SslConnectorBuilder, ErrorStack> {
panic!("Not implemented");
}
pub fn configure(&self) -> Result<ConnectConfiguration, ErrorStack> {
panic!("Not implemented");
}
pub fn context(&self) -> &SslContextRef {
panic!("Not implemented");
}
}
pub struct SslConnectorBuilder;
impl SslConnectorBuilder {
pub fn build(self) -> SslConnector {
panic!("Not implemented");
}
pub fn set_cipher_list(&mut self, _cipher_list: &str) -> Result<(), ErrorStack> {
panic!("Not implemented");
}
pub fn set_sigalgs_list(&mut self, _sigalgs: &str) -> Result<(), ErrorStack> {
panic!("Not implemented");
}
pub fn set_min_proto_version(
&mut self,
_version: Option<SslVersion>,
) -> Result<(), ErrorStack> {
panic!("Not implemented");
}
pub fn set_max_proto_version(
&mut self,
_version: Option<SslVersion>,
) -> Result<(), ErrorStack> {
panic!("Not implemented");
}
pub fn set_default_verify_paths(&mut self) -> Result<(), ErrorStack> {
panic!("Not implemented");
}
pub fn set_ca_file<P: AsRef<std::path::Path>>(
&mut self,
_file: P,
) -> Result<(), ErrorStack> {
panic!("Not implemented");
}
pub fn set_certificate_file<P: AsRef<std::path::Path>>(
&mut self,
_file: P,
_file_type: SslFiletype,
) -> Result<(), ErrorStack> {
panic!("Not implemented");
}
pub fn set_private_key_file<P: AsRef<std::path::Path>>(
&mut self,
_file: P,
_file_type: SslFiletype,
) -> Result<(), ErrorStack> {
panic!("Not implemented");
}
pub fn set_keylog_callback<F>(&mut self, _callback: F)
where
F: Fn(&SslRef, &str) + 'static + Sync + Send,
{
panic!("Not implemented");
}
}
pub struct SslContext;
impl SslContext {
pub fn builder(_method: SslMethod) -> Result<SslContextBuilder, ErrorStack> {
panic!("Not implemented");
}
}
impl_deref! {SslContext => SslContextRef}
pub struct SslContextBuilder;
impl SslContextBuilder {
pub fn build(self) -> SslContext {
panic!("Not implemented");
}
}
pub struct SslContextRef;
pub struct SslFiletype;
impl SslFiletype {
pub const PEM: SslFiletype = Self {};
}
pub struct SslMethod;
impl SslMethod {
pub fn tls() -> SslMethod {
panic!("Not implemented");
}
}
pub struct SslRef;
impl SslRef {
pub fn set_verify(&mut self, _mode: SslVerifyMode) {
panic!("Not implemented");
}
pub fn current_cipher(&self) -> Option<&SslCipherRef> {
panic!("Not implemented");
}
pub fn set_hostname(&mut self, _hostname: &str) -> Result<(), ErrorStack> {
panic!("Not implemented");
}
pub fn peer_certificate(&self) -> Option<X509> {
panic!("Not implemented");
}
pub fn verify_result(&self) -> X509VerifyResult {
panic!("Not implemented");
}
pub fn version_str(&self) -> &'static str {
panic!("Not implemented");
}
pub fn selected_alpn_protocol(&self) -> Option<&[u8]> {
panic!("Not implemented");
}
pub fn servername(&self, _type_: NameType) -> Option<&str> {
panic!("Not implemented");
}
}
pub struct SslVerifyMode;
impl SslVerifyMode {
pub const PEER: Self = Self {};
pub const NONE: Self = Self {};
}
pub struct SslVersion;
impl SslVersion {
pub const TLS1: SslVersion = Self {};
pub const TLS1_2: SslVersion = Self {};
pub const TLS1_3: SslVersion = Self {};
}
pub fn select_next_proto<'a>(_server: &[u8], _client: &'a [u8]) -> Option<&'a [u8]> {
panic!("Not implemented");
}
}
pub mod ssl_sys {
pub const X509_V_OK: i32 = 0;
pub const X509_V_ERR_INVALID_CALL: i32 = 69;
}
pub mod error {
use super::ssl::Error;
#[derive(Debug)]
pub struct ErrorStack;
impl_display!(ErrorStack);
impl std::error::Error for ErrorStack {}
impl ErrorStack {
pub fn get() -> ErrorStack {
panic!("Not implemented");
}
pub fn errors(&self) -> &[Error] {
panic!("Not implemented");
}
}
}
pub mod x509 {
use super::asn1::{Asn1IntegerRef, Asn1StringRef, Asn1TimeRef};
use super::error::ErrorStack;
use super::hash::{DigestBytes, MessageDigest};
use super::nid::Nid;
#[derive(Debug, Clone)]
pub struct X509;
impl_deref! {X509 => X509Ref}
impl X509 {
pub fn from_pem(_pem: &[u8]) -> Result<X509, ErrorStack> {
panic!("Not implemented");
}
}
pub struct X509NameEntries<'a> {
marker: std::marker::PhantomData<&'a ()>,
}
impl<'a> Iterator for X509NameEntries<'a> {
type Item = &'a X509NameEntryRef;
fn next(&mut self) -> Option<&'a X509NameEntryRef> {
panic!("Not implemented");
}
}
pub struct X509NameEntryRef;
impl X509NameEntryRef {
pub fn data(&self) -> &Asn1StringRef {
panic!("Not implemented");
}
}
pub struct X509NameRef;
impl X509NameRef {
pub fn entries_by_nid(&self, _nid: Nid) -> X509NameEntries<'_> {
panic!("Not implemented");
}
}
pub struct X509Ref;
impl X509Ref {
pub fn subject_name(&self) -> &X509NameRef {
panic!("Not implemented");
}
pub fn digest(&self, _hash_type: MessageDigest) -> Result<DigestBytes, ErrorStack> {
panic!("Not implemented");
}
pub fn not_after(&self) -> &Asn1TimeRef {
panic!("Not implemented");
}
pub fn serial_number(&self) -> &Asn1IntegerRef {
panic!("Not implemented");
}
}
pub struct X509VerifyResult;
impl X509VerifyResult {
pub fn as_raw(&self) -> i32 {
panic!("Not implemented");
}
}
pub mod store {
use super::super::error::ErrorStack;
use super::X509;
pub struct X509StoreBuilder;
impl X509StoreBuilder {
pub fn new() -> Result<X509StoreBuilder, ErrorStack> {
panic!("Not implemented");
}
pub fn build(self) -> X509Store {
panic!("Not implemented");
}
pub fn add_cert(&mut self, _cert: X509) -> Result<(), ErrorStack> {
panic!("Not implemented");
}
}
pub struct X509Store;
impl_deref! {X509Store => X509StoreRef}
pub struct X509StoreRef;
}
pub mod verify {
pub struct X509VerifyParamRef;
}
}
pub mod nid {
pub struct Nid;
impl Nid {
pub const COMMONNAME: Nid = Self {};
pub const ORGANIZATIONNAME: Nid = Self {};
pub const ORGANIZATIONALUNITNAME: Nid = Self {};
}
}
pub mod pkey {
use super::error::ErrorStack;
#[derive(Clone)]
pub struct PKey<T> {
marker: std::marker::PhantomData<T>,
}
impl<T> std::ops::Deref for PKey<T> {
type Target = PKeyRef<T>;
fn deref(&self) -> &PKeyRef<T> {
panic!("Not implemented");
}
}
impl<T> std::ops::DerefMut for PKey<T> {
fn deref_mut(&mut self) -> &mut PKeyRef<T> {
panic!("Not implemented");
}
}
impl PKey<Private> {
pub fn private_key_from_pem(_pem: &[u8]) -> Result<PKey<Private>, ErrorStack> {
panic!("Not implemented");
}
}
pub struct PKeyRef<T> {
marker: std::marker::PhantomData<T>,
}
#[derive(Clone)]
pub enum Private {}
unsafe impl HasPrivate for Private {}
pub unsafe trait HasPrivate {}
}
pub mod hash {
pub struct MessageDigest;
impl MessageDigest {
pub fn sha256() -> MessageDigest {
panic!("Not implemented");
}
}
pub struct DigestBytes;
impl AsRef<[u8]> for DigestBytes {
fn as_ref(&self) -> &[u8] {
panic!("Not implemented");
}
}
}
pub mod asn1 {
use super::bn::BigNum;
use super::error::ErrorStack;
pub struct Asn1IntegerRef;
impl Asn1IntegerRef {
pub fn to_bn(&self) -> Result<BigNum, ErrorStack> {
panic!("Not implemented");
}
}
pub struct Asn1StringRef;
impl Asn1StringRef {
pub fn as_utf8(&self) -> Result<&str, ErrorStack> {
panic!("Not implemented");
}
}
pub struct Asn1TimeRef;
impl_display! {Asn1TimeRef}
}
pub mod bn {
use super::error::ErrorStack;
pub struct BigNum;
impl BigNum {
pub fn to_hex_str(&self) -> Result<&str, ErrorStack> {
panic!("Not implemented");
}
}
}
pub mod ext {
use super::error::ErrorStack;
use super::pkey::{HasPrivate, PKeyRef};
use super::ssl::{Ssl, SslAcceptor, SslRef};
use super::x509::store::X509StoreRef;
use super::x509::verify::X509VerifyParamRef;
use super::x509::X509Ref;
pub fn add_host(_verify_param: &mut X509VerifyParamRef, _host: &str) -> Result<(), ErrorStack> {
panic!("Not implemented");
}
pub fn ssl_set_verify_cert_store(
_ssl: &mut SslRef,
_cert_store: &X509StoreRef,
) -> Result<(), ErrorStack> {
panic!("Not implemented");
}
pub fn ssl_use_certificate(_ssl: &mut SslRef, _cert: &X509Ref) -> Result<(), ErrorStack> {
panic!("Not implemented");
}
pub fn ssl_use_private_key<T>(_ssl: &mut SslRef, _key: &PKeyRef<T>) -> Result<(), ErrorStack>
where
T: HasPrivate,
{
panic!("Not implemented");
}
pub fn clear_error_stack() {}
pub fn ssl_from_acceptor(_acceptor: &SslAcceptor) -> Result<Ssl, ErrorStack> {
panic!("Not implemented");
}
pub fn suspend_when_need_ssl_cert(_ssl: &mut SslRef) {
panic!("Not implemented");
}
pub fn unblock_ssl_cert(_ssl: &mut SslRef) {
panic!("Not implemented");
}
pub fn is_suspended_for_cert(_error: &super::ssl::Error) -> bool {
panic!("Not implemented");
}
pub fn ssl_add_chain_cert(_ssl: &mut SslRef, _cert: &X509Ref) -> Result<(), ErrorStack> {
panic!("Not implemented");
}
pub fn ssl_set_renegotiate_mode_freely(_ssl: &mut SslRef) {}
pub fn ssl_set_groups_list(_ssl: &mut SslRef, _groups: &str) -> Result<(), ErrorStack> {
panic!("Not implemented");
}
pub fn ssl_use_second_key_share(_ssl: &mut SslRef, _enabled: bool) {}
pub unsafe fn ssl_mut(_ssl: &SslRef) -> &mut SslRef {
panic!("Not implemented");
}
}
pub mod tokio_ssl {
use std::pin::Pin;
use std::task::{Context, Poll};
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
use super::error::ErrorStack;
use super::ssl::{Error, Ssl, SslRef};
#[derive(Debug)]
pub struct SslStream<S> {
marker: std::marker::PhantomData<S>,
}
impl<S> SslStream<S> {
pub fn new(_ssl: Ssl, _stream: S) -> Result<Self, ErrorStack> {
panic!("Not implemented");
}
pub async fn connect(self: Pin<&mut Self>) -> Result<(), Error> {
panic!("Not implemented");
}
pub async fn accept(self: Pin<&mut Self>) -> Result<(), Error> {
panic!("Not implemented");
}
pub fn ssl(&self) -> &SslRef {
panic!("Not implemented");
}
pub fn get_ref(&self) -> &S {
panic!("Not implemented");
}
pub fn get_mut(&mut self) -> &mut S {
panic!("Not implemented");
}
}
impl<S> AsyncRead for SslStream<S>
where
S: AsyncRead + AsyncWrite,
{
fn poll_read(
self: Pin<&mut Self>,
_ctx: &mut Context<'_>,
_buf: &mut ReadBuf<'_>,
) -> Poll<std::io::Result<()>> {
panic!("Not implemented");
}
}
impl<S> AsyncWrite for SslStream<S>
where
S: AsyncRead + AsyncWrite,
{
fn poll_write(
self: Pin<&mut Self>,
_ctx: &mut Context<'_>,
_buf: &[u8],
) -> Poll<std::io::Result<usize>> {
panic!("Not implemented");
}
fn poll_flush(self: Pin<&mut Self>, _ctx: &mut Context<'_>) -> Poll<std::io::Result<()>> {
panic!("Not implemented");
}
fn poll_shutdown(
self: Pin<&mut Self>,
_ctx: &mut Context<'_>,
) -> Poll<std::io::Result<()>> {
panic!("Not implemented");
}
}
}