Turn "dirty hack" into slightly less dirty hack, with potential to become non-dirty
This commit is contained in:
parent
14a2f5c5e9
commit
c4e398d397
|
|
@ -103,23 +103,15 @@ impl X509StoreContext {
|
||||||
pub use self::extension::KeyUsageOption as KeyUsage;
|
pub use self::extension::KeyUsageOption as KeyUsage;
|
||||||
pub use self::extension::ExtKeyUsageOption as ExtKeyUsage;
|
pub use self::extension::ExtKeyUsageOption as ExtKeyUsage;
|
||||||
|
|
||||||
// FIXME: a dirty hack as there is no way to
|
// FIXME: This would be nicer as a method on Iterator<Item=ToString>. This can
|
||||||
// implement ToString for Vec as both are defined
|
// eventually be replaced by the successor to std::slice::SliceConcatExt.connect
|
||||||
// in another crate
|
fn join<I: Iterator<Item=T>,T: ToString>(iter: I, sep: &str) -> String {
|
||||||
#[doc(hidden)]
|
iter.enumerate().fold(String::new(), |mut acc, (idx, v)| {
|
||||||
trait ToStr {
|
if idx > 0 { acc.push_str(sep) };
|
||||||
fn to_str(&self) -> String;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: ToString> ToStr for Vec<T> {
|
|
||||||
fn to_str(&self) -> String {
|
|
||||||
self.iter().enumerate().fold(String::new(), |mut acc, (idx, v)| {
|
|
||||||
if idx > 0 { acc.push(',') };
|
|
||||||
acc.push_str(&v.to_string());
|
acc.push_str(&v.to_string());
|
||||||
acc
|
acc
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
/// Generator of private key/certificate pairs
|
/// Generator of private key/certificate pairs
|
||||||
|
|
@ -314,12 +306,12 @@ impl X509Generator {
|
||||||
|
|
||||||
if self.key_usage.len() > 0 {
|
if self.key_usage.len() > 0 {
|
||||||
try!(X509Generator::add_extension(x509.handle, ffi::NID_key_usage,
|
try!(X509Generator::add_extension(x509.handle, ffi::NID_key_usage,
|
||||||
&self.key_usage.to_str()));
|
&join(self.key_usage.iter(),",")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.ext_key_usage.len() > 0 {
|
if self.ext_key_usage.len() > 0 {
|
||||||
try!(X509Generator::add_extension(x509.handle, ffi::NID_ext_key_usage,
|
try!(X509Generator::add_extension(x509.handle, ffi::NID_ext_key_usage,
|
||||||
&self.ext_key_usage.to_str()));
|
&join(self.ext_key_usage.iter(),",")));
|
||||||
}
|
}
|
||||||
|
|
||||||
let hash_fn = self.hash_type.evp_md();
|
let hash_fn = self.hash_type.evp_md();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue