parseOCSPResponse static method

OCSPResponse parseOCSPResponse(
  1. Uint8List bytes
)

Parses an OCSPResponse from the given bytes received by an OCSP responder.

Will return OCSPResponse

Implementation

static OCSPResponse parseOCSPResponse(Uint8List bytes) {
  var parser = ASN1Parser(bytes);
  var topLevel = parser.nextObject() as ASN1Sequence;
  var responseStatus = topLevel.elements!.elementAt(0) as ASN1Integer;
  var v = responseStatus.integer!.toInt();

  var ocspResponseStatus = _getOCSPResponseStatus(v);
  var basicOcspResponse;
  if (topLevel.elements!.length == 2) {
    basicOcspResponse =
        _getBasicOCSPResponse(topLevel.elements!.elementAt(1));
  }

  return OCSPResponse(
    ocspResponseStatus,
    basicOCSPResponse: basicOcspResponse,
  );
}