diff --git a/openssl/src/x509/sbgp.rs b/openssl/src/x509/sbgp.rs index 7175979d95..4ca6b43b53 100644 --- a/openssl/src/x509/sbgp.rs +++ b/openssl/src/x509/sbgp.rs @@ -1,20 +1,25 @@ use std::mem::MaybeUninit; +#[cfg(ossl110)] use ffi::{ ASIdOrRange_id, ASIdOrRange_range, ASIdentifierChoice_asIdsOrRanges, ASIdentifierChoice_inherit, IPAddressChoice_addressesOrRanges, X509v3_addr_get_afi, X509v3_addr_get_range, ASN1_INTEGER, IANA_AFI_IPV4, IANA_AFI_IPV6, }; +#[cfg(ossl110)] use foreign_types::{ForeignType, ForeignTypeRef}; +#[cfg(ossl110)] use crate::{ asn1::Asn1IntegerRef, stack::{Stack, StackRef, Stackable}, util::{ForeignTypeExt, ForeignTypeRefExt}, }; +#[cfg(ossl110)] use super::X509; +#[cfg(ossl110)] foreign_type_and_impl_send_sync! { type CType = ffi::ASIdOrRange; fn drop = ffi::ASIdOrRange_free; @@ -24,11 +29,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 +45,7 @@ foreign_type_and_impl_send_sync! { pub struct ASIdentifiersRef; } +#[cfg(ossl110)] impl ASIdentifiers { pub fn inherited(&self) -> bool { unsafe { @@ -109,16 +116,19 @@ foreign_type_and_impl_send_sync! { pub struct IPAddressFamilyRef; } +#[cfg(ossl110)] impl Stackable for IPAddressFamily { type StackType = ffi::stack_st_IPAddressFamily; } #[derive(PartialEq, Eq, Debug)] +#[cfg(ossl110)] pub enum IPVersion { V4, V6, } +#[cfg(ossl110)] impl IPAddressFamily { pub fn fam(&self) -> Option { let ptr = self.0; @@ -180,11 +190,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..a54911d372 100644 --- a/openssl/src/x509/tests.rs +++ b/openssl/src/x509/tests.rs @@ -1,5 +1,7 @@ use std::cmp::Ordering; +#[cfg(ossl110)] use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; +#[cfg(ossl110)] use std::str::FromStr; use crate::asn1::{Asn1Object, Asn1OctetString, Asn1Time}; @@ -12,9 +14,14 @@ use crate::rsa::Rsa; use crate::ssl::SslFiletype; use crate::stack::Stack; use crate::x509::extension::{ - AuthorityKeyIdentifier, BasicConstraints, ExtendedKeyUsage, KeyUsage, SbgpAsIdentifier, - SbgpIpAddressIdentifier, SubjectAlternativeName, SubjectKeyIdentifier, + AuthorityKeyIdentifier, BasicConstraints, ExtendedKeyUsage, KeyUsage, + SubjectAlternativeName, SubjectKeyIdentifier, +}; +#[cfg(ossl110)] +use crate::x509::extension::{ + SbgpAsIdentifier, SbgpIpAddressIdentifier, }; +#[cfg(ossl110)] use crate::x509::sbgp::ExtractSBGPInfo; #[cfg(not(boringssl))] use crate::x509::store::X509Lookup; @@ -1182,6 +1189,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 +1218,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()