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
#![forbid(unsafe_code)]
pub use rustls::{self, Certificate, PrivateKey};
mod cipher_suite;
mod error;
mod session;
pub mod certificate;
pub mod client;
pub mod server;
pub use client::Client;
pub use server::Server;
static PROTOCOL_VERSIONS: &[&rustls::SupportedProtocolVersion] = &[&rustls::version::TLS13];
const QUIC_VERSION: rustls::quic::Version = rustls::quic::Version::V1;
pub(crate) fn encode_transport_parameters<Params: s2n_codec::EncoderValue>(
params: &Params,
) -> Vec<u8> {
let len = params.encoding_size();
let mut buffer = vec![0; len];
params.encode(&mut s2n_codec::EncoderBuffer::new(&mut buffer));
buffer
}
#[test]
fn client_server_test() {
use s2n_quic_core::crypto::tls::{self, testing::certificates::*};
let mut client = client::Builder::new()
.with_certificate(CERT_PEM)
.unwrap()
.build()
.unwrap();
let mut server = server::Builder::new()
.with_certificate(CERT_PEM, KEY_PEM)
.unwrap()
.build()
.unwrap();
let mut pair = tls::testing::Pair::new(&mut server, &mut client, "localhost".into());
while pair.is_handshaking() {
pair.poll(None).unwrap();
}
pair.finish();
}