code: public static CRLReason getRevocationReason(X509CRLEntry crlEntry) {
          try {
              byte[] ext = crlEntry.getExtensionValue("2.5.29.21");
              if (ext == null) {
                  return null;
              }
              DerValue val = new DerValue(ext);
              byte[] data = val.getOctetString();
  
              CRLReasonCodeExtension rcExt =
                  new CRLReasonCodeExtension(Boolean.FALSE, data);
              return rcExt.getReasonCode();
          } catch (IOException ioe) {
              return null;
          }
      }
docs: This static method is the default implementation of the
  getRevocationReason method in X509CRLEntry.