[pdm-devel] [PATCH datacenter-manager v3 03/23] server: connection: add probe_tls_connection helper

Lukas Wagner l.wagner at proxmox.com
Thu Aug 21 13:46:01 CEST 2025


On Thu Aug 21, 2025 at 10:39 AM CEST, Dominik Csapak wrote:
> +/// Checks TLS connection to the given remote
> +///
> +/// Returns `Ok(None)` if connecting with the given parameters works
> +/// Returns `Ok(Some(cert))` if no fingerprint was given and some certificate could not be validated
> +/// Returns `Err(err)` if some other error occurred
> +///
> +/// # Example
> +///
> +/// ```
> +/// use server::connection::probe_tls_connection;
> +/// use pdm_api_types::remotes::RemoteType;
> +///
> +/// # async fn function() {
> +/// let result = probe_tls_connection(RemoteType::Pve, "192.168.2.100".to_string(), None).await;
> +/// match result {
> +///     Ok(None) => { /* everything ok */ },
> +///     Ok(Some(cert)) => { /* do something with cert */ },
> +///     Err(err) => { /* do something with error */ },
> +/// }
> +/// # }
> +/// ```

^ The doc comment is now outdated

> +pub async fn probe_tls_connection(
> +    remote_type: RemoteType,
> +    hostname: String,
> +    fingerprint: Option<String>,
> +) -> Result<TlsProbeOutcome, Error> {
> +    let host_port: Authority = hostname.parse()?;
> +
> +    let uri: http::uri::Uri = format!(
> +        "https://{}:{}",
> +        host_port.host(),
> +        host_port.port_u16().unwrap_or(remote_type.default_port())
> +    )
> +    .parse()?;





More information about the pdm-devel mailing list