@@ -21,7 +21,7 @@ use clap::Parser;
2121use grpc:: { client:: CoreClient , operations:: jsongrpc:: client:: JsonGrpcClient } ;
2222use http:: Uri ;
2323use rustls:: { pki_types:: PrivateKeyDer , ServerConfig } ;
24- use rustls_pemfile:: { certs, rsa_private_keys } ;
24+ use rustls_pemfile:: { certs, pkcs8_private_keys } ;
2525use std:: { fs:: File , io:: BufReader , time:: Duration } ;
2626use stor_port:: transport_api:: { RequestMinTimeout , TimeoutOptions } ;
2727use utils:: {
@@ -157,8 +157,10 @@ fn get_certificates() -> anyhow::Result<ServerConfig> {
157157 // guaranteed to be `Some` by the require_unless attribute
158158 let cert_file = CliArgs :: args ( ) . cert_file . expect ( "cert_file is required" ) ;
159159 let key_file = CliArgs :: args ( ) . key_file . expect ( "key_file is required" ) ;
160+ println ! ( "getcertificates: cert_file: {:?}, key_file: {:?}" , cert_file, key_file) ;
160161 let cert_file = & mut BufReader :: new ( File :: open ( cert_file) ?) ;
161162 let key_file = & mut BufReader :: new ( File :: open ( key_file) ?) ;
163+ println ! ( "key_file get cert: {:?}" , key_file) ;
162164 load_certificates ( cert_file, key_file)
163165 }
164166}
@@ -170,27 +172,32 @@ fn get_dummy_certificates() -> anyhow::Result<ServerConfig> {
170172 load_certificates ( cert_file, key_file)
171173}
172174
173- fn load_certificates < R : std:: io:: Read > (
175+ fn load_certificates < R : std:: io:: Read + std :: fmt :: Debug > (
174176 cert_file : & mut BufReader < R > ,
175177 key_file : & mut BufReader < R > ,
176178) -> anyhow:: Result < ServerConfig > {
179+ println ! ( "Key file: {:?}" , key_file) ;
180+ println ! ( "Cert file: {:?}" , cert_file) ;
177181 let config = ServerConfig :: builder ( ) ;
178182 let cert_chain = certs ( cert_file)
179183 . collect :: < Result < Vec < _ > , _ > > ( )
180184 . map_err ( |_| {
181185 anyhow:: anyhow!( "Failed to retrieve certificates from the certificate file" , )
182186 } ) ?;
183- let mut keys = rsa_private_keys ( key_file)
187+ let mut keys: Vec < rustls :: pki_types :: PrivatePkcs8KeyDer < ' _ > > = pkcs8_private_keys ( key_file)
184188 . collect :: < Result < Vec < _ > , _ > > ( )
185189 . map_err ( |_| {
186190 anyhow:: anyhow!( "Failed to retrieve the rsa private keys from the key file" , )
187191 } ) ?;
192+
193+ println ! ( "keys: {:?}" , keys) ;
194+
188195 if keys. is_empty ( ) {
189196 anyhow:: bail!( "No keys found in the keys file" ) ;
190197 }
191198 let config = config
192199 . with_no_client_auth ( )
193- . with_single_cert ( cert_chain, PrivateKeyDer :: Pkcs1 ( keys. remove ( 0 ) ) ) ?;
200+ . with_single_cert ( cert_chain, PrivateKeyDer :: Pkcs8 ( keys. remove ( 0 ) ) ) ?;
194201 Ok ( config)
195202}
196203
0 commit comments