@@ -3,6 +3,7 @@ use std::{path::PathBuf, sync::Arc};
3
3
4
4
use anyhow:: { bail, Context , Result } ;
5
5
use quinn:: crypto:: rustls:: { QuicClientConfig , QuicServerConfig } ;
6
+ use rustls:: pki_types:: { CertificateDer , PrivatePkcs8KeyDer } ;
6
7
use tokio:: fs;
7
8
8
9
pub const EXAMPLE_ALPN : & [ u8 ] = b"n0/iroh/examples/bytes/0" ;
@@ -40,22 +41,19 @@ pub async fn make_and_write_certs() -> Result<(
40
41
let key_path = path. join ( "key.der" ) ;
41
42
let cert_path = path. join ( "cert.der" ) ;
42
43
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 ( ) ;
45
46
tokio:: fs:: create_dir_all ( path)
46
47
. await
47
48
. context ( "failed to create certificate directory" ) ?;
48
49
tokio:: fs:: write ( cert_path, & cert)
49
50
. await
50
51
. context ( "failed to write certificate" ) ?;
51
- tokio:: fs:: write ( key_path, & key)
52
+ tokio:: fs:: write ( key_path, key. secret_pkcs8_der ( ) )
52
53
. await
53
54
. context ( "failed to write private key" ) ?;
54
55
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) )
59
57
}
60
58
61
59
// derived from `quinn/examples/client.rs`
0 commit comments