1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
extern crate tls_api;
extern crate void;
use std::io;
use std::result;
use std::fmt;
use std::error::Error as std_Error;
use void::Void;
use tls_api::Result;
pub struct Pkcs12(Void);
pub struct Certificate(Void);
pub struct TlsConnectorBuilder(Void);
pub struct TlsConnector(Void);
pub struct TlsAcceptorBuilder(Void);
pub struct TlsAcceptor(Void);
#[derive(Debug)]
struct Error;
impl std_Error for Error {
fn description(&self) -> &str {
"stub implementation"
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(self.description(), f)
}
}
impl tls_api::Pkcs12 for Pkcs12 {
fn from_der(_der: &[u8], _password: &str) -> Result<Self> {
Err(tls_api::Error::new(Error))
}
}
impl tls_api::Certificate for Certificate {
fn from_der(_der: &[u8]) -> Result<Self> where Self: Sized {
Err(tls_api::Error::new(Error))
}
}
impl tls_api::TlsConnectorBuilder for TlsConnectorBuilder {
type Connector = TlsConnector;
fn add_root_certificate(&mut self, _cert: Certificate) -> Result<&mut Self> {
Err(tls_api::Error::new(Error))
}
fn build(self) -> Result<TlsConnector> {
Err(tls_api::Error::new(Error))
}
}
impl tls_api::TlsConnector for TlsConnector {
type Builder = TlsConnectorBuilder;
type Certificate = Certificate;
fn builder() -> Result<TlsConnectorBuilder> {
Err(tls_api::Error::new(Error))
}
fn connect<S>(&self, _domain: &str, _stream: S)
-> result::Result<tls_api::TlsStream<S>, tls_api::HandshakeError<S>>
where S: io::Read + io::Write + fmt::Debug + 'static
{
Err(tls_api::HandshakeError::Failure(tls_api::Error::new(Error)))
}
fn danger_connect_without_providing_domain_for_certificate_verification_and_server_name_indication<S>(
&self,
_stream: S)
-> result::Result<tls_api::TlsStream<S>, tls_api::HandshakeError<S>>
where S: io::Read + io::Write + fmt::Debug + 'static
{
Err(tls_api::HandshakeError::Failure(tls_api::Error::new(Error)))
}
}
impl tls_api::TlsAcceptorBuilder for TlsAcceptorBuilder {
type Acceptor = TlsAcceptor;
fn build(self) -> Result<TlsAcceptor> {
Err(tls_api::Error::new(Error))
}
}
impl tls_api::TlsAcceptor for TlsAcceptor {
type Pkcs12 = Pkcs12;
type Builder = TlsAcceptorBuilder;
fn builder(_pkcs12: Pkcs12) -> Result<TlsAcceptorBuilder> {
Err(tls_api::Error::new(Error))
}
fn accept<S>(&self, _stream: S)
-> result::Result<tls_api::TlsStream<S>, tls_api::HandshakeError<S>>
where S: io::Read + io::Write + fmt::Debug + 'static
{
Err(tls_api::HandshakeError::Failure(tls_api::Error::new(Error)))
}
}