Skip to content

Commit 4702461

Browse files
committed
1 parent 1d91d91 commit 4702461

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/io/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,11 @@ impl Endpoint {
175175
let mut builder = TlsConnector::builder();
176176
match ssl_opts.root_cert_path() {
177177
Some(root_cert_path) => {
178-
let mut root_cert_der = vec![];
178+
let mut root_cert_data = vec![];
179179
let mut root_cert_file = File::open(root_cert_path)?;
180-
root_cert_file.read_to_end(&mut root_cert_der)?;
181-
let root_cert = Certificate::from_der(&*root_cert_der)?;
180+
root_cert_file.read_to_end(&mut root_cert_data)?;
181+
let root_cert = Certificate::from_pem(&*root_cert_data)
182+
.or_else(|_| Certificate::from_der(&*root_cert_data))?;
182183
builder.add_root_certificate(root_cert);
183184
}
184185
None => (),

src/opts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ pub struct SslOpts {
136136
}
137137

138138
impl SslOpts {
139-
/// Sets path to the pkcs12 archive.
139+
/// Sets path to the pkcs12 archive (in `der` format).
140140
pub fn with_pkcs12_path<T: Into<Cow<'static, Path>>>(mut self, pkcs12_path: Option<T>) -> Self {
141141
self.pkcs12_path = pkcs12_path.map(Into::into);
142142
self
@@ -148,7 +148,7 @@ impl SslOpts {
148148
self
149149
}
150150

151-
/// Sets path to a der certificate of the root that connector will trust.
151+
/// Sets path to a `pem` or `der` certificate of the root that connector will trust.
152152
pub fn with_root_cert_path<T: Into<Cow<'static, Path>>>(
153153
mut self,
154154
root_cert_path: Option<T>,

0 commit comments

Comments
 (0)