Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config::trust_cert_ca should take Into<PathBuf> instead of ToString #336

Open
olback opened this issue Apr 1, 2024 · 0 comments
Open

Config::trust_cert_ca should take Into<PathBuf> instead of ToString #336

olback opened this issue Apr 1, 2024 · 0 comments

Comments

@olback
Copy link

olback commented Apr 1, 2024

The Config::trust_cert_ca method currently takes a path-parameter that looks like this: path: impl ToString which then gets converted to a PathBuf. Is there a reason the trust_cert_ca method doesn't take a PathBuf directly? I'd argue it would be more correct since there are valid paths that are not valid UTF-8 strings.

Current impl:

pub fn trust_cert_ca(&mut self, path: impl ToString) {
    if let TrustConfig::TrustAll = &self.trust {
        panic!("'trust_cert' and 'trust_cert_ca' are mutual exclusive! Only use one.")
    } else {
        self.trust = TrustConfig::CaCertificateLocation(PathBuf::from(path.to_string()))
    }
}

Proposed impl:

pub fn trust_cert_ca(&mut self, path: impl Into<PathBuf>) {
    if let TrustConfig::TrustAll = &self.trust {
        panic!("'trust_cert' and 'trust_cert_ca' are mutual exclusive! Only use one.")
    } else {
        self.trust = TrustConfig::CaCertificateLocation(path.into())
    }
}

I'd be happy to send a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant