FetchOCSPResponse

Digital signatures

Requires the Enterprise edition — in Delphi, C++Builder and Lazarus code create the library as TPDFlibEnterprise (unit PDFlibEnterprise); the Enterprise DLL and ActiveX builds provide it unchanged; other editions keep the method, which returns an empty string and sets LastErrorCode to 900 (PDFLIB_ERROR_ENTERPRISE_REQUIRED)

Description

Asks an OCSP responder for the status of a certificate and returns the reply

Syntax

Delphi

Function TPDFlib.FetchOCSPResponse(Const SubjectCertDER, IssuerCertDER: AnsiString; Const ResponderURL: WideString): AnsiString; Virtual;

DLL

const char* DLFetchOCSPResponse(int InstanceID, const char* SubjectCertDER, int SubjectCertDERLength, const char* IssuerCertDER, int IssuerCertDERLength, const wchar_t* ResponderURL, int* ByteCount);
const char* DLFetchOCSPResponseA(int InstanceID, const char* SubjectCertDER, int SubjectCertDERLength, const char* IssuerCertDER, int IssuerCertDERLength, const char* ResponderURL, int* ByteCount);

ActiveX

Function PDFlib::FetchOCSPResponse(SubjectCertDER As Variant, IssuerCertDER As Variant, ResponderURL As String) As Variant

Parameters

SubjectCertDERThe certificate whose status is being asked about, DER encoded
IssuerCertDERThe certificate that issued it, DER encoded
ResponderURLThe responder address, or an empty string to use the one the subject certificate names in its Authority Information Access extension

Return values

ResponseThe OCSPResponse bytes, ready for the document security store
Empty stringThe exchange failed or the responder did not answer successful; GetTimeStampError carries the reason

Remarks

Only a successful response is returned. A responder that answered tryLater or unauthorized sent an error report, not a status answer, and storing it would leave a validator parsing the wrong structure

The timeout is the one set by SetTimeStampOptions

Example

Response:= PDF.FetchOCSPResponse(SignerCert, IssuerCert, '');
if Response= '' then
  ShowMessage(PDF.GetTimeStampError);

See also

BuildOCSPRequest, AddPAdESDSSOCSPFromCertificates