Commit a6fcef01 authored by Steven Fackler's avatar Steven Fackler
Browse files

Overhaul openssl cfgs

Also expose hostname verification on libressl
parent 9df40304
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -1413,15 +1413,15 @@ pub const X509_V_ERR_EMAIL_MISMATCH: c_int = 63;
#[cfg(ossl102)]
pub const X509_V_ERR_IP_ADDRESS_MISMATCH: c_int = 64;

#[cfg(ossl102)]
#[cfg(any(ossl102, libressl261))]
pub const X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT: c_uint = 0x1;
#[cfg(ossl102)]
#[cfg(any(ossl102, libressl261))]
pub const X509_CHECK_FLAG_NO_WILDCARDS: c_uint = 0x2;
#[cfg(ossl102)]
#[cfg(any(ossl102, libressl261))]
pub const X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS: c_uint = 0x4;
#[cfg(ossl102)]
#[cfg(any(ossl102, libressl261))]
pub const X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS: c_uint = 0x8;
#[cfg(ossl102)]
#[cfg(any(ossl102, libressl261))]
pub const X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS: c_uint = 0x10;

pub const GEN_OTHERNAME: c_int = 0;
+22 −0
Original line number Diff line number Diff line
@@ -447,6 +447,28 @@ pub unsafe fn SSL_session_reused(ssl: *mut ::SSL) -> c_int {
    ::SSL_ctrl(ssl, SSL_CTRL_GET_SESSION_REUSED, 0, ptr::null_mut()) as c_int
}

pub unsafe fn SSL_CTX_get_options(ctx: *const ::SSL_CTX) -> c_ulong {
    ::SSL_CTX_ctrl(ctx as *mut _, ::SSL_CTRL_OPTIONS, 0, ptr::null_mut()) as c_ulong
}

pub unsafe fn SSL_CTX_set_options(ctx: *const ::SSL_CTX, op: c_ulong) -> c_ulong {
    ::SSL_CTX_ctrl(
        ctx as *mut _,
        ::SSL_CTRL_OPTIONS,
        op as c_long,
        ptr::null_mut(),
    ) as c_ulong
}

pub unsafe fn SSL_CTX_clear_options(ctx: *const ::SSL_CTX, op: c_ulong) -> c_ulong {
    ::SSL_CTX_ctrl(
        ctx as *mut _,
        ::SSL_CTRL_CLEAR_OPTIONS,
        op as c_long,
        ptr::null_mut(),
    ) as c_ulong
}

extern "C" {
    pub fn BIO_new(type_: *mut BIO_METHOD) -> *mut BIO;
    pub fn BIO_s_file() -> *mut BIO_METHOD;
+22 −0
Original line number Diff line number Diff line
@@ -807,6 +807,28 @@ pub unsafe fn SSL_session_reused(ssl: *mut ::SSL) -> c_int {
    ::SSL_ctrl(ssl, SSL_CTRL_GET_SESSION_REUSED, 0, ptr::null_mut()) as c_int
}

pub unsafe fn SSL_CTX_get_options(ctx: *const ::SSL_CTX) -> c_ulong {
    ::SSL_CTX_ctrl(ctx as *mut _, ::SSL_CTRL_OPTIONS, 0, ptr::null_mut()) as c_ulong
}

pub unsafe fn SSL_CTX_set_options(ctx: *const ::SSL_CTX, op: c_ulong) -> c_ulong {
    ::SSL_CTX_ctrl(
        ctx as *mut _,
        ::SSL_CTRL_OPTIONS,
        op as c_long,
        ptr::null_mut(),
    ) as c_ulong
}

pub unsafe fn SSL_CTX_clear_options(ctx: *const ::SSL_CTX, op: c_ulong) -> c_ulong {
    ::SSL_CTX_ctrl(
        ctx as *mut _,
        ::SSL_CTRL_CLEAR_OPTIONS,
        op as c_long,
        ptr::null_mut(),
    ) as c_ulong
}

extern "C" {
    pub fn BIO_new(type_: *mut BIO_METHOD) -> *mut BIO;
    pub fn BIO_s_file() -> *mut BIO_METHOD;
+2 −0
Original line number Diff line number Diff line
@@ -18,9 +18,11 @@ v111 = []

[dependencies]
bitflags = "1.0"
cfg-if = "0.1"
foreign-types = "0.3.1"
lazy_static = "1"
libc = "0.2"

openssl-sys = { version = "0.9.30", path = "../openssl-sys" }

[dev-dependencies]
+12 −19
Original line number Diff line number Diff line
use std::env;

fn main() {
    match env::var("DEP_OPENSSL_VERSION") {
        Ok(ref v) if v == "101" => {
            println!("cargo:rustc-cfg=ossl101");
            println!("cargo:rustc-cfg=ossl10x");
        }
        Ok(ref v) if v == "102" => {
            println!("cargo:rustc-cfg=ossl102");
            println!("cargo:rustc-cfg=ossl10x");
        }
        Ok(ref v) if v == "110" => {
            println!("cargo:rustc-cfg=ossl110");
        }
        Ok(ref v) if v == "111" => {
            println!("cargo:rustc-cfg=ossl110");
            println!("cargo:rustc-cfg=ossl111");
        }
        _ => panic!("Unable to detect OpenSSL version"),
    }

    if let Ok(_) = env::var("DEP_OPENSSL_LIBRESSL") {
        println!("cargo:rustc-cfg=libressl");
    }
@@ -37,9 +18,21 @@ fn main() {
    if let Ok(version) = env::var("DEP_OPENSSL_VERSION_NUMBER") {
        let version = u64::from_str_radix(&version, 16).unwrap();

        if version >= 0x1_00_01_00_0 {
            println!("cargo:rustc-cfg=ossl101");
        }
        if version >= 0x1_00_02_00_0 {
            println!("cargo:rustc-cfg=ossl102");
        }
        if version >= 0x1_01_00_00_0 {
            println!("cargo:rustc-cfg=ossl110");
        }
        if version >= 0x1_01_00_07_0 {
            println!("cargo:rustc-cfg=ossl110g");
        }
        if version >= 0x1_01_01_00_0 {
            println!("cargo:rustc-cfg=ossl111");
        }
    }

    if let Ok(version) = env::var("DEP_OPENSSL_LIBRESSL_VERSION_NUMBER") {
Loading