@@ -1746,6 +1746,17 @@ unsafe impl ExtensionType for CertificateIssuer {
1746
1746
type Output = Stack < GeneralName > ;
1747
1747
}
1748
1748
1749
+ /// The CRL extension identifying how to access information and services for the issuer of the CRL
1750
+ pub enum AuthorityInformationAccess { }
1751
+
1752
+ // SAFETY: AuthorityInformationAccess is defined to be a stack of AccessDescription in the RFC
1753
+ // and in OpenSSL.
1754
+ unsafe impl ExtensionType for AuthorityInformationAccess {
1755
+ const NID : Nid = Nid :: from_raw ( ffi:: NID_info_access ) ;
1756
+
1757
+ type Output = Stack < AccessDescription > ;
1758
+ }
1759
+
1749
1760
foreign_type_and_impl_send_sync ! {
1750
1761
type CType = ffi:: X509_CRL ;
1751
1762
fn drop = ffi:: X509_CRL_free ;
@@ -1915,6 +1926,36 @@ impl X509CrlRef {
1915
1926
{
1916
1927
unsafe { cvt_n ( ffi:: X509_CRL_verify ( self . as_ptr ( ) , key. as_ptr ( ) ) ) . map ( |n| n != 0 ) }
1917
1928
}
1929
+
1930
+ /// Get the criticality and value of an extension.
1931
+ ///
1932
+ /// This returns None if the extension is not present or occurs multiple times.
1933
+ #[ corresponds( X509_CRL_get_ext_d2i ) ]
1934
+ pub fn extension < T : ExtensionType > ( & self ) -> Result < Option < ( bool , T :: Output ) > , ErrorStack > {
1935
+ let mut critical = -1 ;
1936
+ let out = unsafe {
1937
+ // SAFETY: self.as_ptr() is a valid pointer to an X509_CRL.
1938
+ let ext = ffi:: X509_CRL_get_ext_d2i (
1939
+ self . as_ptr ( ) ,
1940
+ T :: NID . as_raw ( ) ,
1941
+ & mut critical as * mut _ ,
1942
+ ptr:: null_mut ( ) ,
1943
+ ) ;
1944
+ // SAFETY: Extensions's contract promises that the type returned by
1945
+ // OpenSSL here is T::Output.
1946
+ T :: Output :: from_ptr_opt ( ext as * mut _ )
1947
+ } ;
1948
+ match ( critical, out) {
1949
+ ( 0 , Some ( out) ) => Ok ( Some ( ( false , out) ) ) ,
1950
+ ( 1 , Some ( out) ) => Ok ( Some ( ( true , out) ) ) ,
1951
+ // -1 means the extension wasn't found, -2 means multiple were found.
1952
+ ( -1 | -2 , _) => Ok ( None ) ,
1953
+ // A critical value of 0 or 1 suggests success, but a null pointer
1954
+ // was returned so something went wrong.
1955
+ ( 0 | 1 , None ) => Err ( ErrorStack :: get ( ) ) ,
1956
+ ( c_int:: MIN ..=-2 | 2 .., _) => panic ! ( "OpenSSL should only return -2, -1, 0, or 1 for an extension's criticality but it returned {}" , critical) ,
1957
+ }
1958
+ }
1918
1959
}
1919
1960
1920
1961
/// The result of peer certificate verification.
0 commit comments