@@ -3,6 +3,7 @@ use std::{path::PathBuf, sync::Arc};
33
44use anyhow:: { bail, Context , Result } ;
55use quinn:: crypto:: rustls:: { QuicClientConfig , QuicServerConfig } ;
6+ use rustls:: pki_types:: { CertificateDer , PrivatePkcs8KeyDer } ;
67use tokio:: fs;
78
89pub const EXAMPLE_ALPN : & [ u8 ] = b"n0/iroh/examples/bytes/0" ;
@@ -40,22 +41,19 @@ pub async fn make_and_write_certs() -> Result<(
4041 let key_path = path. join ( "key.der" ) ;
4142 let cert_path = path. join ( "cert.der" ) ;
4243
43- let key = cert. serialize_private_key_der ( ) ;
44- let cert = cert. serialize_der ( ) . unwrap ( ) ;
44+ let key = PrivatePkcs8KeyDer :: from ( cert. key_pair . serialize_der ( ) ) ;
45+ let cert: CertificateDer = cert. cert . into ( ) ;
4546 tokio:: fs:: create_dir_all ( path)
4647 . await
4748 . context ( "failed to create certificate directory" ) ?;
4849 tokio:: fs:: write ( cert_path, & cert)
4950 . await
5051 . context ( "failed to write certificate" ) ?;
51- tokio:: fs:: write ( key_path, & key)
52+ tokio:: fs:: write ( key_path, key. secret_pkcs8_der ( ) )
5253 . await
5354 . context ( "failed to write private key" ) ?;
5455
55- Ok ( (
56- rustls:: pki_types:: PrivateKeyDer :: try_from ( key) . unwrap ( ) ,
57- rustls:: pki_types:: CertificateDer :: from ( cert) ,
58- ) )
56+ Ok ( ( rustls:: pki_types:: PrivateKeyDer :: from ( key) , cert) )
5957}
6058
6159// derived from `quinn/examples/client.rs`
0 commit comments