From 3bf5d759580112f5283863cea0ee2941ce256c72 Mon Sep 17 00:00:00 2001 From: Markus Theil Date: Thu, 12 Oct 2023 16:19:41 +0200 Subject: [PATCH] mark supported OpenSSL version range Signed-off-by: Markus Theil --- openssl/src/x509/sbgp.rs | 10 +++++++++- openssl/src/x509/tests.rs | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/openssl/src/x509/sbgp.rs b/openssl/src/x509/sbgp.rs index 7175979d95..40bf5ecdb4 100644 --- a/openssl/src/x509/sbgp.rs +++ b/openssl/src/x509/sbgp.rs @@ -1,5 +1,6 @@ use std::mem::MaybeUninit; +#[cfg(ossl110)] use ffi::{ ASIdOrRange_id, ASIdOrRange_range, ASIdentifierChoice_asIdsOrRanges, ASIdentifierChoice_inherit, IPAddressChoice_addressesOrRanges, X509v3_addr_get_afi, @@ -15,6 +16,7 @@ use crate::{ use super::X509; +#[cfg(ossl110)] foreign_type_and_impl_send_sync! { type CType = ffi::ASIdOrRange; fn drop = ffi::ASIdOrRange_free; @@ -24,11 +26,12 @@ foreign_type_and_impl_send_sync! { /// Reference to `ASIdOrRange`. pub struct ASIdOrRangeRef; } - +#[cfg(ossl110)] impl Stackable for ASIdOrRange { type StackType = ffi::stack_st_ASIdOrRange; } +#[cfg(ossl110)] foreign_type_and_impl_send_sync! { type CType = ffi::ASIdentifiers; fn drop = ffi::ASIdentifiers_free; @@ -39,6 +42,7 @@ foreign_type_and_impl_send_sync! { pub struct ASIdentifiersRef; } +#[cfg(ossl110)] impl ASIdentifiers { pub fn inherited(&self) -> bool { unsafe { @@ -109,6 +113,7 @@ foreign_type_and_impl_send_sync! { pub struct IPAddressFamilyRef; } +#[cfg(ossl110)] impl Stackable for IPAddressFamily { type StackType = ffi::stack_st_IPAddressFamily; } @@ -119,6 +124,7 @@ pub enum IPVersion { V6, } +#[cfg(ossl110)] impl IPAddressFamily { pub fn fam(&self) -> Option { let ptr = self.0; @@ -180,11 +186,13 @@ impl IPAddressFamily { } } +#[cfg(ossl110)] pub trait ExtractSBGPInfo { fn asn(&self) -> Option; fn ip_addresses(&self) -> Option>; } +#[cfg(ossl110)] impl ExtractSBGPInfo for X509 { fn asn(&self) -> Option { unsafe { diff --git a/openssl/src/x509/tests.rs b/openssl/src/x509/tests.rs index bdd6137954..6b82891de2 100644 --- a/openssl/src/x509/tests.rs +++ b/openssl/src/x509/tests.rs @@ -15,6 +15,7 @@ use crate::x509::extension::{ AuthorityKeyIdentifier, BasicConstraints, ExtendedKeyUsage, KeyUsage, SbgpAsIdentifier, SbgpIpAddressIdentifier, SubjectAlternativeName, SubjectKeyIdentifier, }; +#[cfg(ossl110)] use crate::x509::sbgp::ExtractSBGPInfo; #[cfg(not(boringssl))] use crate::x509::store::X509Lookup; @@ -1182,6 +1183,7 @@ fn test_dist_point_null() { } #[test] +#[cfg(ossl110)] fn test_sbgp_extensions_parsing() { let cert = include_bytes!("../../test/rfc3779.pem"); let cert = X509::from_pem(cert).unwrap(); @@ -1210,6 +1212,7 @@ fn test_sbgp_extensions_parsing() { } #[test] +#[cfg(ossl110)] fn test_sbgp_extensions_builder() { let mut builder = X509Builder::new().unwrap(); let asn_ext = SbgpAsIdentifier::new()