SSE4E

Home

GPError
GPSystem
ByteString
ByteBuffer
TLV
TLVList
Card
Atr
Key
Crypto
Application GPApplication GPSecDomain

ASN1
CardFile
IsoSecureChannel
ApplFactory
GPXML
JsScript
CardSim

X509
CRL
KeyStore
CMSSignedData
CMSGenerator
XMLSignature
OCSPQuery
LDAP
SOAP
URLConnection

PKCS11Provider
PKCS11Session
PKCS11Object

OutlineNode

OpenSCDP

OCSPQuery - Reference Documentation

Class implementing support for the Online Certificate Status Protocol (OCSP)

Index of Methods

Constants

TypeNameDescription
NumberGOODCertificate is valid
NumberUNKNOWNCertificate is unknown to the responder
NumberREVOKEDCertificate was revoked
NumberKEYCOMPROMISECertificate was revoked because the key was compromised
NumberCACOMPROMISECertificate was revoked because the CA key was compromised
NumberAFFILIATIONCHANGEDCertificate was revoked because the affiliation changed
NumberSUPERSEDEDCertificate was revoked because a new certificate was issued
NumberCESSATIONOFOPERATIONCertificate was revoked because the CA discontinued operation
NumberCERTIFICATEHOLDCertificate is on hold
NumberREMOVEFROMCRLCertificate was revoked and can now be removed form CRL
NumberPRIVILEGEWITHDRAWNCertificate was revoked because the privileges granted by to the owner were withdrawn
NumberAACOMPROMISECertificate was revoked

Constructor

Prototype

OCSPQuery(X509 rootCert, X509 issuerCert)

OCSPQuery(X509 issuerCert)

Description

Create OCSPQuery object that can be used to collect certificates for which the the status can be queried from an OCSP responder.

The URL for the OCSP responder is taken from isserCert.

If the root certificate is ommited from the constructor, then the signature on the OCSP response is only validated against the list of certificates in the OCSPResponse. No link to a trusted anchor is verified in that case.

Arguments

TypeNameDescription
X509rootCertRoot certificate used for verification of OCSP response signature
X509issuerCertCertificate of instance that issued the certificate for which a query should be done.

Exceptions

NameValueDescription
GPErrorGPError.ARGUMENTS_MISSINGToo few arguments in call
GPErrorGPError.INVALID_ARGUMENTSToo many arguments in call
GPErrorGPError.INVALID_TYPEArguments must be of type X509

Example


rootcert = new X509("root.cer");
cacert = new X509("ca.cer");

query = new OCSPQuery(cacert);

query = new OCSPQuery(rootcert, cacert);

add()

Prototype

OCSPQuery add(X509 cert)

Description

Add a certificate to the query. The certificate must be issued by the instance identified by the isserCert certificate in the OCSPQuery constructor. Multiple certificates can be included in a single query.

Arguments

TypeNameDescription
X509certCertificate to include in query

Return

OCSPQueryThe object this method is applied to

Exceptions

NameValueDescription
GPErrorGPError.ARGUMENTS_MISSINGToo few arguments in call
GPErrorGPError.INVALID_ARGUMENTSToo many arguments in call
GPErrorGPError.INVALID_TYPEType of argument is invalid for call
GPErrorGPError.INVALID_DATACertificate is invalid for inclusion in query

Example


goodcert = new X509("ee_good.cer");
revokedcert = new X509("ee_revoked.cer");

query.add(goodcert);
assert(query.add(revokedcert) instanceof OCSPQuery);

execute()

Prototype

OCSPQuery execute()

Description

Execute query against OCSP server. This is a one in all method. It extracts the URL from the issuer certificate, builds the request, posts the message, obtains the response and decodes the status information.

Return

OCSPQueryThe object this method is applied to

Exceptions

NameValueDescription
GPErrorGPError.INVALID_ARGUMENTSToo many arguments in call
GPErrorGPError.DEVICE_ERRORThe query could not be completed successfully

Example


assert(query.execute() instanceof OCSPQuery);

post()

Prototype

OCSPQuery post(String url, ByteString request)

OCSPQuery post(String url, ByteString request, String[] header)

Description

Send a request to the server identified by the url with a custom HTTP header. This method is suitable for test setups using custom build requests and header fields.

Arguments

TypeNameDescription
StringurlURL of OCSP responder.
ByteStringrequestDER encoded request
String[]headerCustom HTTP header field in the format "key: value". Will disable automatically generated header fields Content-Type and Content-Length.

Return

ByteStringThe response returned from the server

Exceptions

NameValueDescription
GPErrorGPError.ARGUMENTS_MISSINGToo few arguments in call
GPErrorGPError.INVALID_ARGUMENTSToo many arguments in call
GPErrorGPError.INVALID_TYPEOne or more arguments do not match
GPErrorGPError.DEVICE_ERRORThe query could not be completed successfully

Example


var request = query.getRequest();
var response = query.post("http://ocsp.ecard.sozialversicherung.at", request);
assert(response.length > 0);

var header = [ "Content-Length: " + request.length, "Content-Type: application/ocsp-request" ];
var response = query.post("http://ocsp.ecard.sozialversicherung.at", request, header);
assert(response.length > 0);

getStatus()

Prototype

Number getStatus(X509 cert)

Description

Query status from cached result of previous query operation

Arguments

TypeNameDescription
X509certCertificate in question

Return

NumberStatus of the certificate as indicated by the responder. This is one of the constant values defined for this object.

Exceptions

NameValueDescription
GPErrorGPError.ARGUMENTS_MISSINGToo few arguments in call
GPErrorGPError.INVALID_ARGUMENTSToo many arguments in call
GPErrorGPError.INVALID_TYPEArguments must be of type X509
GPErrorGPError.DEVICE_ERRORThe query could not be completed successfully

Example


assert(query.getStatus(goodcert) == OCSPQuery.GOOD);
assert(query.getStatus(revokedcert) != OCSPQuery.GOOD);

getStatusString()

Prototype

String getStatusString(X509 cert)

Description

Query status from cached result of previous query operation and return a human readable string

Arguments

TypeNameDescription
X509certCertificate in question

Return

StringStatus of the certificate as indicated by the responder.

Exceptions

NameValueDescription
GPErrorGPError.ARGUMENTS_MISSINGToo few arguments in call
GPErrorGPError.INVALID_ARGUMENTSToo many arguments in call
GPErrorGPError.INVALID_TYPEArguments must be of type X509
GPErrorGPError.DEVICE_ERRORThe query could not be completed successfully

Example


print("ee_good.cer    : " + query.getStatusString(goodcert));
print("ee_revoked.cer : " + query.getStatusString(revokedcert));

getRevocationTime()

Prototype

Date getRevocationTime(X509 cert)

Description

Query revocation time from cached result of previous query operation

Arguments

TypeNameDescription
X509certCertificate in question

Return

DateRevocation time of the certificate as indicated by the responder.

Exceptions

NameValueDescription
GPErrorGPError.ARGUMENTS_MISSINGToo few arguments in call
GPErrorGPError.INVALID_ARGUMENTSToo many arguments in call
GPErrorGPError.INVALID_TYPEArguments must be of type X509
GPErrorGPError.DEVICE_ERRORThe query could not be completed successfully

Example


var rt = query.getRevocationTime(revokedcert);
assert(rt instanceof Date);
print("ee_revoked.cer : " + rt);

getRequest()

Prototype

ByteString getRequest()

Description

Obtain DER encoded OCSP request

Return

ByteStringDER encoded request.

Exceptions

NameValueDescription
GPErrorGPError.INVALID_ARGUMENTSToo many arguments in call
GPErrorGPError.DEVICE_ERRORAn error occured building the request

Example


req = query.getRequest();
assert(req instanceof ByteString);
print(req.toString(HEX));

getResponse()

Prototype

ByteString getResponse()

Description

Obtain DER encoded OCSP response as returned from OCSP server

Return

ByteStringDER encoded response.

Exceptions

NameValueDescription
GPErrorGPError.INVALID_ARGUMENTSToo many arguments in call
GPErrorGPError.DEVICE_ERRORAn error occured building the response

Example


res = query.getResponse();
assert(res instanceof ByteString);
print(res.toString(HEX));