Commit 1ac54b06 authored by Steven Fackler's avatar Steven Fackler
Browse files

Move X509_get_extensions to openssl helpers

parent 0854632f
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -138,7 +138,3 @@ DH *DH_new_from_params(BIGNUM *p, BIGNUM *g, BIGNUM *q) {
long SSL_set_tlsext_host_name_shim(SSL *s, char *name) {
    return SSL_set_tlsext_host_name(s, name);
}

STACK_OF(X509_EXTENSION) *X509_get_extensions_shim(X509 *x) {
    return x->cert_info ? x->cert_info->extensions : NULL;
}
+1 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ pkcs5_pbkdf2_hmac = ["openssl-sys/pkcs5_pbkdf2_hmac"]

c_helpers = ["gcc"]
x509_clone = ["c_helpers"]
x509_generator_request = ["c_helpers"]
ssl_context_clone = ["c_helpers"]

[dependencies]
+4 −0
Original line number Diff line number Diff line
@@ -7,3 +7,7 @@ void rust_SSL_CTX_clone(SSL_CTX *ctx) {
void rust_X509_clone(X509 *x509) {
    CRYPTO_add(&x509->references,1,CRYPTO_LOCK_X509);
}

STACK_OF(X509_EXTENSION) *rust_X509_get_extensions(X509 *x) {
    return x->cert_info ? x->cert_info->extensions : NULL;
}
+1 −0
Original line number Diff line number Diff line
@@ -4,4 +4,5 @@ use ffi;
extern "C" {
    pub fn rust_SSL_CTX_clone(cxt: *mut ffi::SSL_CTX);
    pub fn rust_X509_clone(x509: *mut ffi::X509);
    pub fn rust_X509_get_extensions(x: *mut ffi::X509) -> *mut ffi::stack_st_X509_EXTENSION;
}
+4 −2
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ use crypto::hash::Type as HashType;
use crypto::pkey::PKey;
use crypto::rand::rand_bytes;
use ffi;
use ffi_extras;
use nid::Nid;
use error::ErrorStack;

@@ -346,6 +345,9 @@ impl X509Generator {
    }

    /// Obtain a certificate signing request (CSR)
    ///
    /// Requries the `x509_generator_request` feature.
    #[cfg(feature = "x509_generator_request")]
    pub fn request(&self, p_key: &PKey) -> Result<X509Req, ErrorStack> {
        let cert = match self.sign(p_key) {
            Ok(c) => c,
@@ -356,7 +358,7 @@ impl X509Generator {
            let req = ffi::X509_to_X509_REQ(cert.handle(), ptr::null_mut(), ptr::null());
            try_ssl_null!(req);

            let exts = ffi_extras::X509_get_extensions(cert.handle());
            let exts = ::c_helpers::rust_X509_get_extensions(cert.handle());
            if exts != ptr::null_mut() {
                try_ssl!(ffi::X509_REQ_add_extensions(req, exts));
            }
Loading