Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler committed Nov 6, 2016
1 parent 8ad1e55 commit 79e2004
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions openssl/src/ssl/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! SSL/TLS support.
//!
//! The `SslConnector` and `SslAcceptor` should be used in most cases - they handle
//! `SslConnector` and `SslAcceptor` should be used in most cases - they handle
//! configuration of the OpenSSL primitives for you.
//!
//! # Examples
Expand Down Expand Up @@ -70,7 +70,9 @@
//! }
//! }
//! ```
use ffi;
use libc::{c_int, c_void, c_long, c_ulong};
use libc::{c_uchar, c_uint};
use std::any::Any;
use std::any::TypeId;
use std::cmp;
Expand All @@ -79,15 +81,14 @@ use std::ffi::{CStr, CString};
use std::fmt;
use std::io;
use std::io::prelude::*;
use std::marker::PhantomData;
use std::mem;
use std::ops::{Deref, DerefMut};
use std::path::Path;
use std::ptr;
use std::slice;
use std::str;
use std::sync::Mutex;
use libc::{c_uchar, c_uint};
use std::slice;
use std::marker::PhantomData;
use ffi;

use {init, cvt, cvt_p};
use dh::DhRef;
Expand Down Expand Up @@ -781,6 +782,20 @@ impl OpenSslType for SslCipher {
}
}

impl Deref for SslCipher {
type Target = SslCipherRef;

fn deref(&self) -> &SslCipherRef {
unsafe { SslCipherRef::from_ptr(self.0) }
}
}

impl DerefMut for SslCipher {
fn deref_mut(&mut self) -> &mut SslCipherRef {
unsafe { SslCipherRef::from_ptr_mut(self.0) }
}
}

pub struct SslCipherRef(Opaque);

impl OpenSslTypeRef for SslCipherRef {
Expand All @@ -789,7 +804,7 @@ impl OpenSslTypeRef for SslCipherRef {

impl SslCipherRef {
/// Returns the name of cipher.
pub fn name(&self) -> &'static str {
pub fn name(&self) -> &str {
let name = unsafe {
let ptr = ffi::SSL_CIPHER_get_name(self.as_ptr());
CStr::from_ptr(ptr as *const _)
Expand All @@ -799,7 +814,7 @@ impl SslCipherRef {
}

/// Returns the SSL/TLS protocol version that first defined the cipher.
pub fn version(&self) -> &'static str {
pub fn version(&self) -> &str {
let version = unsafe {
let ptr = ffi::SSL_CIPHER_get_version(self.as_ptr());
CStr::from_ptr(ptr as *const _)
Expand Down

0 comments on commit 79e2004

Please sign in to comment.