Skip to content

Commit 7139cc6

Browse files
cpujsha
authored andcommitted
cipher: lift rustls_certificate_get_der out of impl block
For some reason, since adding a lifetime to the `rustls_certificate` type, the `rustls_certificate_get_der` fn inside the `impl rustls_certificate` block isn't being picked up by cbindgen, removing it from the `rustls.h` generated header file. This commit lifts the fn out of the `impl` block into a free-standing function, now its properly included in `rustls.h` again.
1 parent 238e1a7 commit 7139cc6

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

src/cipher.rs

+18-20
Original file line numberDiff line numberDiff line change
@@ -44,27 +44,25 @@ impl<'a> Castable for rustls_certificate<'a> {
4444
type RustType = CertificateDer<'a>;
4545
}
4646

47-
impl<'a> rustls_certificate<'a> {
48-
/// Get the DER data of the certificate itself.
49-
/// The data is owned by the certificate and has the same lifetime.
50-
#[no_mangle]
51-
pub extern "C" fn rustls_certificate_get_der(
52-
cert: *const rustls_certificate,
53-
out_der_data: *mut *const u8,
54-
out_der_len: *mut size_t,
55-
) -> rustls_result {
56-
ffi_panic_boundary! {
57-
let cert = try_ref_from_ptr!(cert);
58-
if out_der_data.is_null() || out_der_len.is_null() {
59-
return NullParameter
60-
}
61-
let der = cert.as_ref();
62-
unsafe {
63-
*out_der_data = der.as_ptr();
64-
*out_der_len = der.len();
65-
}
66-
rustls_result::Ok
47+
/// Get the DER data of the certificate itself.
48+
/// The data is owned by the certificate and has the same lifetime.
49+
#[no_mangle]
50+
pub extern "C" fn rustls_certificate_get_der(
51+
cert: *const rustls_certificate,
52+
out_der_data: *mut *const u8,
53+
out_der_len: *mut size_t,
54+
) -> rustls_result {
55+
ffi_panic_boundary! {
56+
let cert = try_ref_from_ptr!(cert);
57+
if out_der_data.is_null() || out_der_len.is_null() {
58+
return NullParameter
6759
}
60+
let der = cert.as_ref();
61+
unsafe {
62+
*out_der_data = der.as_ptr();
63+
*out_der_len = der.len();
64+
}
65+
rustls_result::Ok
6866
}
6967
}
7068

src/rustls.h

+8
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,14 @@ rustls_result rustls_accepted_into_connection(struct rustls_accepted *accepted,
836836
*/
837837
void rustls_accepted_free(struct rustls_accepted *accepted);
838838

839+
/**
840+
* Get the DER data of the certificate itself.
841+
* The data is owned by the certificate and has the same lifetime.
842+
*/
843+
rustls_result rustls_certificate_get_der(const struct rustls_certificate *cert,
844+
const uint8_t **out_der_data,
845+
size_t *out_der_len);
846+
839847
/**
840848
* Return a 16-bit unsigned integer corresponding to this cipher suite's assignment from
841849
* <https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4>.

0 commit comments

Comments
 (0)