code: private static ObjectNode encodeCacheToJSON()
    {
      try
      {
        ObjectNode out = OBJECT_MAPPER.createObjectNode();
        for (Map.Entry<OcspResponseCacheKey, SFPair<Long, String>> elem :
            OCSP_RESPONSE_CACHE.entrySet())
        {
          OcspResponseCacheKey key = elem.getKey();
          SFPair<Long, String> value0 = elem.getValue();
          long currentTimeSecond = value0.left;
  
          DigestCalculator digest = new SHA1DigestCalculator();
          AlgorithmIdentifier algo = digest.getAlgorithmIdentifier();
          ASN1OctetString nameHash = ASN1OctetString.getInstance(key.nameHash);
          ASN1OctetString keyHash = ASN1OctetString.getInstance(key.keyHash);
          ASN1Integer serialNumber = new ASN1Integer(key.serialNumber);
          CertID cid = new CertID(algo, nameHash, keyHash, serialNumber);
          ArrayNode vout = OBJECT_MAPPER.createArrayNode();
          vout.add(currentTimeSecond);
          vout.add(value0.right);
          out.set(
              Base64.encodeBase64String(cid.toASN1Primitive().getEncoded()),
              vout);
        }
        return out;
      }
      catch (IOException ex)
      {
        LOGGER.debug("Failed to encode ASN1 object.");
      }
      return null;
    }
docs: Encode OCSP Response Cache to JSON
  
  @return JSON object