Add setters to new getter-functions in X509ReqRef

This commit is contained in:
mredlek 2017-01-27 20:55:40 +01:00
parent 6a8f6f425f
commit f5149eac5a
3 changed files with 16 additions and 3 deletions

View File

@ -1935,6 +1935,9 @@ extern {
pub fn X509_REQ_add_extensions(req: *mut X509_REQ, exts: *mut stack_st_X509_EXTENSION) -> c_int;
pub fn X509_REQ_sign(x: *mut X509_REQ, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> c_int;
pub fn X509_REQ_set_version(x: *mut X509_REQ, version: c_long) -> c_int;
pub fn X509_REQ_set_subject_name(req: *mut X509_REQ, name: *mut ::X509_NAME) -> c_int;
#[cfg(not(ossl101))]
pub fn X509_VERIFY_PARAM_free(param: *mut X509_VERIFY_PARAM);

View File

@ -193,8 +193,5 @@ extern {
mac_iter: c_int,
keytype: c_int) -> *mut PKCS12;
pub fn X509_REQ_get_version(req: *const X509_REQ) -> c_long;
pub fn X509_REQ_set_version(x: *mut X509_REQ, version: c_long) -> c_int;
pub fn X509_REQ_get_subject_name(req: *const X509_REQ) -> *mut ::X509_NAME;
pub fn X509_REQ_set_subject_name(req: *mut X509_REQ, name: *mut ::X509_NAME) -> c_int;
}

View File

@ -607,12 +607,25 @@ impl X509ReqRef {
}
}
pub fn set_version(&mut self, value: i32) -> Result<(), ErrorStack>
{
unsafe {
cvt(ffi::X509_REQ_set_version(self.as_ptr(), value as c_long)).map(|_| ())
}
}
pub fn subject_name(&self) -> &X509NameRef {
unsafe {
let name = compat::X509_REQ_get_subject_name(self.as_ptr());
X509NameRef::from_ptr(name)
}
}
pub fn set_subject_name(&self, value: &X509NameRef) -> Result<(), ErrorStack> {
unsafe {
cvt(ffi::X509_REQ_set_subject_name(self.as_ptr(), value.as_ptr())).map(|_| ())
}
}
}
/// A collection of X.509 extensions.