Initialize OpenSSL in DSA constructor
This fixes the double unlock errors that were popping up on circle
This commit is contained in:
parent
a02f039c0c
commit
01927c19ac
|
|
@ -3,6 +3,7 @@ use std::sync::{Once, ONCE_INIT};
|
|||
use std::mem;
|
||||
use std::ptr;
|
||||
use std::process;
|
||||
use std::io::{self, Write};
|
||||
|
||||
use libc::{c_int, c_char, c_void, c_long, c_uchar, size_t, c_uint, c_ulong};
|
||||
#[cfg(not(ossl101))]
|
||||
|
|
@ -748,7 +749,11 @@ unsafe extern "C" fn locking_function(mode: c_int, n: c_int, _file: *const c_cha
|
|||
(*GUARDS)[n as usize] = Some(mutex.lock().unwrap());
|
||||
} else {
|
||||
if let None = (*GUARDS)[n as usize].take() {
|
||||
println!("lock {} already unlocked", n);
|
||||
let _ = writeln!(
|
||||
io::stderr(),
|
||||
"BUG: rust-openssl lock {} already unlocked, aborting",
|
||||
n
|
||||
);
|
||||
process::abort();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ impl DsaRef {
|
|||
impl Dsa {
|
||||
/// Generate a DSA key pair.
|
||||
pub fn generate(bits: u32) -> Result<Dsa, ErrorStack> {
|
||||
ffi::init();
|
||||
unsafe {
|
||||
let dsa = Dsa(try!(cvt_p(ffi::DSA_new())));
|
||||
try!(cvt(ffi::DSA_generate_parameters_ex(
|
||||
|
|
|
|||
Loading…
Reference in New Issue