Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

OpenSSL::X509::CRL#by_serial

crl.by_serial(serial) → OpenSSL::X509::Revoked or nil

Looks up the certificate serial (an Integer or OpenSSL::BN) in the CRL and returns the matching OpenSSL::X509::Revoked entry, or nil if that serial is not listed.

Unlike iterating over revoked, this does not instantiate the entire revocation list: it performs a sorted lookup (wrapping the OpenSSL function X509_CRL_get0_by_serial), which is significantly faster and uses far less memory for large CRLs.

Example
crl.by_serial(cert.serial)        #=> #<OpenSSL::X509::Revoked> or nil
crl.by_serial(cert.serial)&.time  #=> revocation time, if revoked