@@ -12,11 +12,13 @@ use std::{io::Write as _, sync::Arc};
12
12
use actix_rt:: net:: TcpStream ;
13
13
use actix_server:: TestServer ;
14
14
use actix_service:: ServiceFactoryExt as _;
15
- use actix_tls:: accept:: openssl:: { Acceptor , TlsStream } ;
15
+ use actix_tls:: {
16
+ accept:: openssl:: { Acceptor , TlsStream } ,
17
+ connect:: rustls_0_22:: reexports:: ClientConfig ,
18
+ } ;
16
19
use actix_utils:: future:: ok;
17
20
use rustls_pki_types_1:: ServerName ;
18
- use tokio_rustls:: rustls:: { ClientConfig , RootCertStore } ;
19
- use tokio_rustls_025 as tokio_rustls;
21
+ use tokio_rustls_025:: rustls:: RootCertStore ;
20
22
21
23
fn new_cert_and_key ( ) -> ( String , String ) {
22
24
let cert =
@@ -47,39 +49,40 @@ fn openssl_acceptor(cert: String, key: String) -> tls_openssl::ssl::SslAcceptor
47
49
builder. build ( )
48
50
}
49
51
50
- #[ allow( dead_code) ]
51
52
mod danger {
53
+ use rustls_pki_types_1:: { CertificateDer , ServerName , UnixTime } ;
52
54
use tokio_rustls_025:: rustls;
53
55
56
+ /// Disables certificate verification to allow self-signed certs from rcgen.
54
57
#[ derive( Debug ) ]
55
58
pub struct NoCertificateVerification ;
56
59
57
60
impl rustls:: client:: danger:: ServerCertVerifier for NoCertificateVerification {
58
61
fn verify_server_cert (
59
62
& self ,
60
- end_entity : & rustls_pki_types_1 :: CertificateDer :: CertificateDer < ' _ > ,
61
- intermediates : & [ rustls_pki_types_1 :: CertificateDer :: CertificateDer < ' _ > ] ,
62
- server_name : & rustls_pki_types_1 :: CertificateDer :: ServerName < ' _ > ,
63
- ocsp_response : & [ u8 ] ,
64
- now : rustls_pki_types_1 :: CertificateDer :: UnixTime ,
63
+ _end_entity : & CertificateDer < ' _ > ,
64
+ _intermediates : & [ CertificateDer < ' _ > ] ,
65
+ _server_name : & ServerName < ' _ > ,
66
+ _ocsp_response : & [ u8 ] ,
67
+ _now : UnixTime ,
65
68
) -> Result < rustls:: client:: danger:: ServerCertVerified , rustls:: Error > {
66
69
Ok ( rustls:: client:: danger:: ServerCertVerified :: assertion ( ) )
67
70
}
68
71
69
72
fn verify_tls12_signature (
70
73
& self ,
71
- message : & [ u8 ] ,
72
- cert : & rustls_pki_types_1:: CertificateDer < ' _ > ,
73
- dss : & rustls:: DigitallySignedStruct ,
74
+ _message : & [ u8 ] ,
75
+ _cert : & rustls_pki_types_1:: CertificateDer < ' _ > ,
76
+ _dss : & rustls:: DigitallySignedStruct ,
74
77
) -> Result < rustls:: client:: danger:: HandshakeSignatureValid , rustls:: Error > {
75
78
Ok ( rustls:: client:: danger:: HandshakeSignatureValid :: assertion ( ) )
76
79
}
77
80
78
81
fn verify_tls13_signature (
79
82
& self ,
80
- message : & [ u8 ] ,
81
- cert : & rustls_pki_types_1:: CertificateDer < ' _ > ,
82
- dss : & rustls:: DigitallySignedStruct ,
83
+ _message : & [ u8 ] ,
84
+ _cert : & rustls_pki_types_1:: CertificateDer < ' _ > ,
85
+ _dss : & rustls:: DigitallySignedStruct ,
83
86
) -> Result < rustls:: client:: danger:: HandshakeSignatureValid , rustls:: Error > {
84
87
Ok ( rustls:: client:: danger:: HandshakeSignatureValid :: assertion ( ) )
85
88
}
@@ -134,13 +137,13 @@ async fn accepts_connections() {
134
137
let config = rustls_connector ( cert, key) ;
135
138
let config = Arc :: new ( config) ;
136
139
137
- let mut conn = tokio_rustls :: rustls:: ClientConnection :: new (
140
+ let mut conn = tokio_rustls_025 :: rustls:: ClientConnection :: new (
138
141
config,
139
142
ServerName :: try_from ( "localhost" ) . unwrap ( ) ,
140
143
)
141
144
. unwrap ( ) ;
142
145
143
- let mut stream = tokio_rustls :: rustls:: Stream :: new ( & mut conn, & mut sock) ;
146
+ let mut stream = tokio_rustls_025 :: rustls:: Stream :: new ( & mut conn, & mut sock) ;
144
147
145
148
stream. flush ( ) . expect ( "TLS handshake failed" ) ;
146
149
}
0 commit comments