1010#[ cfg( feature = "server" ) ]
1111use std:: net:: IpAddr ;
1212use std:: num:: NonZeroU128 ;
13+ use std:: path:: PathBuf ;
1314
1415use clap:: Args ;
1516use katana_genesis:: Genesis ;
@@ -188,6 +189,29 @@ pub struct ServerOptions {
188189 #[ arg( default_value_t = DEFAULT_RPC_MAX_CALL_GAS ) ]
189190 #[ serde( default = "default_max_call_gas" ) ]
190191 pub max_call_gas : u64 ,
192+
193+ /// Enable HTTPS with auto-generated self-signed certificates.
194+ ///
195+ /// When this flag is set, Katana will automatically generate a self-signed certificate
196+ /// and private key for development purposes. The certificates will be stored in the
197+ /// `.katana/tls` directory.
198+ ///
199+ /// Note: This is for development only. For production, use `--http.tls-cert` and
200+ /// `--http.tls-key` with proper certificates from a trusted CA.
201+ #[ arg( long = "https" ) ]
202+ #[ arg( conflicts_with_all = [ "tls_cert" , "tls_key" ] ) ]
203+ #[ serde( default ) ]
204+ pub https : bool ,
205+
206+ /// Path to TLS certificate file (PEM format) for HTTPS.
207+ #[ arg( long = "http.tls-cert" , value_name = "PATH" ) ]
208+ #[ arg( requires = "tls_key" ) ]
209+ pub tls_cert : Option < PathBuf > ,
210+
211+ /// Path to TLS private key file (PEM format) for HTTPS.
212+ #[ arg( long = "http.tls-key" , value_name = "PATH" ) ]
213+ #[ arg( requires = "tls_cert" ) ]
214+ pub tls_key : Option < PathBuf > ,
191215}
192216
193217#[ cfg( feature = "server" ) ]
@@ -205,6 +229,9 @@ impl Default for ServerOptions {
205229 max_response_body_size : None ,
206230 timeout : None ,
207231 max_call_gas : DEFAULT_RPC_MAX_CALL_GAS ,
232+ https : false ,
233+ tls_cert : None ,
234+ tls_key : None ,
208235 }
209236 }
210237}
@@ -246,6 +273,15 @@ impl ServerOptions {
246273 if self . max_call_gas == DEFAULT_RPC_MAX_CALL_GAS {
247274 self . max_call_gas = other. max_call_gas ;
248275 }
276+ if !self . https {
277+ self . https = other. https ;
278+ }
279+ if self . tls_cert . is_none ( ) {
280+ self . tls_cert = other. tls_cert . clone ( ) ;
281+ }
282+ if self . tls_key . is_none ( ) {
283+ self . tls_key = other. tls_key . clone ( ) ;
284+ }
249285 }
250286 }
251287}
0 commit comments