@@ -63,9 +63,49 @@ impl MintRPCServer {
63
63
let server = match tls_dir {
64
64
Some ( tls_dir) => {
65
65
tracing:: info!( "TLS configuration found, starting secure server" ) ;
66
- let cert = std:: fs:: read_to_string ( tls_dir. join ( "server.pem" ) ) ?;
67
- let key = std:: fs:: read_to_string ( tls_dir. join ( "server.key" ) ) ?;
68
- let client_ca_cert = std:: fs:: read_to_string ( tls_dir. join ( "ca.pem" ) ) ?;
66
+ let server_pem_path = tls_dir. join ( "server.pem" ) ;
67
+ let server_key_path = tls_dir. join ( "server.key" ) ;
68
+ let ca_pem_path = tls_dir. join ( "ca.pem" ) ;
69
+
70
+ if !server_pem_path. exists ( ) {
71
+ tracing:: error!(
72
+ "Server certificate file does not exist: {}" ,
73
+ server_pem_path. display( )
74
+ ) ;
75
+ return Err ( Error :: Io ( std:: io:: Error :: new (
76
+ std:: io:: ErrorKind :: NotFound ,
77
+ format ! (
78
+ "Server certificate file not found: {}" ,
79
+ server_pem_path. display( )
80
+ ) ,
81
+ ) ) ) ;
82
+ }
83
+
84
+ if !server_key_path. exists ( ) {
85
+ tracing:: error!(
86
+ "Server key file does not exist: {}" ,
87
+ server_key_path. display( )
88
+ ) ;
89
+ return Err ( Error :: Io ( std:: io:: Error :: new (
90
+ std:: io:: ErrorKind :: NotFound ,
91
+ format ! ( "Server key file not found: {}" , server_key_path. display( ) ) ,
92
+ ) ) ) ;
93
+ }
94
+
95
+ if !ca_pem_path. exists ( ) {
96
+ tracing:: error!(
97
+ "CA certificate file does not exist: {}" ,
98
+ ca_pem_path. display( )
99
+ ) ;
100
+ return Err ( Error :: Io ( std:: io:: Error :: new (
101
+ std:: io:: ErrorKind :: NotFound ,
102
+ format ! ( "CA certificate file not found: {}" , ca_pem_path. display( ) ) ,
103
+ ) ) ) ;
104
+ }
105
+
106
+ let cert = std:: fs:: read_to_string ( & server_pem_path) ?;
107
+ let key = std:: fs:: read_to_string ( & server_key_path) ?;
108
+ let client_ca_cert = std:: fs:: read_to_string ( & ca_pem_path) ?;
69
109
let client_ca_cert = Certificate :: from_pem ( client_ca_cert) ;
70
110
let server_identity = Identity :: from_pem ( cert, key) ;
71
111
let tls_config = ServerTlsConfig :: new ( )
0 commit comments