-
-
Notifications
You must be signed in to change notification settings - Fork 749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bindings for config loading, add_builtin for statically linked provider #2034
Open
marcbrevoort-cyberhive
wants to merge
5
commits into
sfackler:master
Choose a base branch
from
CyberHive:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2e3dbe6
Feature/load config file (#1)
shickey-ch 3e1b0b6
Feature/add builtin (#2)
marcbrevoort-cyberhive 778f358
Feature/load config file (#1)
shickey-ch 8adff02
Feature/add builtin (#2)
marcbrevoort-cyberhive 6c6b871
Merge pull request #5 from CyberHive/rebase/openssl-v0.10.63
shickey-ch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
use super::super::*; | ||
|
||
pub const CONF_MFLAGS_IGNORE_ERRORS: c_ulong = 0x1; | ||
pub const CONF_MFLAGS_IGNORE_RETURN_CODES: c_ulong = 0x2; | ||
pub const CONF_MFLAGS_SILENT: c_ulong = 0x4; | ||
pub const CONF_MFLAGS_NO_DSO: c_ulong = 0x8; | ||
pub const CONF_MFLAGS_IGNORE_MISSING_FILE: c_ulong = 0x10; | ||
pub const CONF_MFLAGS_DEFAULT_SECTION: c_ulong = 0x20; | ||
|
||
extern "C" { | ||
pub fn NCONF_new(meth: *mut CONF_METHOD) -> *mut CONF; | ||
pub fn NCONF_default() -> *mut CONF_METHOD; | ||
pub fn NCONF_free(conf: *mut CONF); | ||
pub fn CONF_modules_load_file( | ||
filename: *const c_char, | ||
appname: *const c_char, | ||
flags: c_ulong, | ||
) -> c_int; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,10 +11,43 @@ foreign_type_and_impl_send_sync! { | |
#[cfg(not(boringssl))] | ||
mod methods { | ||
use super::Conf; | ||
use crate::cvt; | ||
use crate::cvt_p; | ||
use crate::error::ErrorStack; | ||
use libc::{c_int, c_ulong}; | ||
use openssl_macros::corresponds; | ||
use std::ffi::CString; | ||
use std::path::Path; | ||
use std::ptr; | ||
|
||
#[derive(Copy, Clone, PartialEq, Eq)] | ||
pub struct ConfMflags(c_ulong); | ||
|
||
impl ConfMflags { | ||
pub const IGNORE_ERRORS: ConfMflags = ConfMflags(ffi::CONF_MFLAGS_IGNORE_ERRORS); | ||
pub const IGNORE_RETURN_CODES: ConfMflags = | ||
ConfMflags(ffi::CONF_MFLAGS_IGNORE_RETURN_CODES); | ||
pub const SILENT: ConfMflags = ConfMflags(ffi::CONF_MFLAGS_SILENT); | ||
pub const NO_DSO: ConfMflags = ConfMflags(ffi::CONF_MFLAGS_NO_DSO); | ||
pub const IGNORE_MISSING_FILE: ConfMflags = | ||
ConfMflags(ffi::CONF_MFLAGS_IGNORE_MISSING_FILE); | ||
pub const DEFAULT_SECTION: ConfMflags = ConfMflags(ffi::CONF_MFLAGS_DEFAULT_SECTION); | ||
pub const DEFAULT_CONF_MFLAGS: ConfMflags = ConfMflags( | ||
ffi::CONF_MFLAGS_DEFAULT_SECTION | ||
| ffi::CONF_MFLAGS_IGNORE_MISSING_FILE | ||
| ffi::CONF_MFLAGS_IGNORE_RETURN_CODES, | ||
); | ||
|
||
/// Constructs an `ConfMflags` from a raw OpenSSL value. | ||
pub fn from_raw(id: c_ulong) -> Self { | ||
ConfMflags(id) | ||
} | ||
|
||
/// Returns the raw OpenSSL value represented by this type. | ||
pub fn as_raw(&self) -> c_ulong { | ||
self.0 | ||
} | ||
} | ||
pub struct ConfMethod(*mut ffi::CONF_METHOD); | ||
|
||
impl ConfMethod { | ||
|
@@ -60,6 +93,29 @@ mod methods { | |
unsafe { cvt_p(ffi::NCONF_new(method.as_ptr())).map(Conf) } | ||
} | ||
} | ||
|
||
/// configures OpenSSL using file filename and application name appname. | ||
/// If filename is None the standard OpenSSL configuration file is used | ||
/// If appname is None the standard OpenSSL application name openssl_conf is used. | ||
/// The behaviour can be customized using flags. | ||
#[corresponds(CONF_modules_load_file)] | ||
pub fn modules_load_file<P: AsRef<Path>>( | ||
filename: Option<P>, | ||
appname: Option<String>, | ||
flags: ConfMflags, | ||
) -> Result<c_int, ErrorStack> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you'll want an |
||
let filename = | ||
filename.map(|f| CString::new(f.as_ref().as_os_str().to_str().unwrap()).unwrap()); | ||
let appname = appname.map(|a| CString::new(a).unwrap()); | ||
|
||
unsafe { | ||
cvt(ffi::CONF_modules_load_file( | ||
filename.as_ref().map_or(ptr::null(), |f| f.as_ptr()), | ||
appname.as_ref().map_or(ptr::null(), |a| a.as_ptr()), | ||
flags.as_raw() as _, | ||
)) | ||
} | ||
} | ||
} | ||
#[cfg(not(boringssl))] | ||
pub use methods::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be generated with the
bitflags
macro.