@@ -28,7 +28,35 @@ pub async fn make_rust_tls(enabled: bool, cert: &Option<String>, key: &Option<St
28
28
29
29
if let ( Some ( cert) , Some ( key) ) = ( cert, key) {
30
30
info ! ( "Using https: cert path: {cert}." ) ;
31
- info ! ( "Using https: key path: {cert}." ) ;
31
+ info ! ( "Using https: key path: {key}." ) ;
32
+
33
+ Some (
34
+ RustlsConfig :: from_pem_file ( cert, key)
35
+ . await
36
+ . map_err ( |err| Error :: BadTlsConfig {
37
+ source : ( Arc :: new ( err) as DynError ) . into ( ) ,
38
+ } ) ,
39
+ )
40
+ } else {
41
+ Some ( Err ( Error :: MissingTlsConfig {
42
+ location : Location :: caller ( ) ,
43
+ } ) )
44
+ }
45
+ }
46
+
47
+ pub async fn make_rust_tls_from_path_buf (
48
+ enabled : bool ,
49
+ cert : & Option < Utf8PathBuf > ,
50
+ key : & Option < Utf8PathBuf > ,
51
+ ) -> Option < Result < RustlsConfig , Error > > {
52
+ if !enabled {
53
+ info ! ( "TLS not enabled" ) ;
54
+ return None ;
55
+ }
56
+
57
+ if let ( Some ( cert) , Some ( key) ) = ( cert, key) {
58
+ info ! ( "Using https: cert path: {cert}." ) ;
59
+ info ! ( "Using https: key path: {key}." ) ;
32
60
33
61
Some (
34
62
RustlsConfig :: from_pem_file ( cert, key)
@@ -77,6 +105,7 @@ use std::panic::Location;
77
105
use std:: sync:: Arc ;
78
106
79
107
use axum_server:: tls_rustls:: RustlsConfig ;
108
+ use camino:: Utf8PathBuf ;
80
109
use log:: info;
81
110
use thiserror:: Error ;
82
111
use torrust_tracker_located_error:: { DynError , LocatedError } ;
0 commit comments