]> git.proxmox.com Git - proxmox-backup.git/blobdiff - src/auth.rs
auth: factor out CA store and cert lookup into own fn
[proxmox-backup.git] / src / auth.rs
index 51b9e8d14e89ebf8308ad1bf7d57f4c6a14baadd..04fb3a1d76c5cb496150ea396eb5cda933354200 100644 (file)
@@ -185,16 +185,7 @@ impl LdapAuthenticator {
             servers.push(server.clone());
         }
 
-        let (ca_store, trusted_cert) = if let Some(capath) = config.capath.as_deref() {
-            let path = PathBuf::from(capath);
-            if path.is_dir() {
-                (Some(path), None)
-            } else {
-                (None, Some(vec![path]))
-            }
-        } else {
-            (None, None)
-        };
+        let (ca_store, trusted_cert) = lookup_ca_store_or_cert_path(config.capath.as_deref());
 
         Ok(Config {
             servers,
@@ -219,6 +210,19 @@ fn ldap_to_conn_mode(mode: LdapMode) -> ConnectionMode {
     }
 }
 
+fn lookup_ca_store_or_cert_path(capath: Option<&str>) -> (Option<PathBuf>, Option<Vec<PathBuf>>) {
+    if let Some(capath) = capath {
+        let path = PathBuf::from(capath);
+        if path.is_dir() {
+            (Some(path), None)
+        } else {
+            (None, Some(vec![path]))
+        }
+    } else {
+        (None, None)
+    }
+}
+
 /// Lookup the authenticator for the specified realm
 pub(crate) fn lookup_authenticator(
     realm: &RealmRef,