The certificate validation policy file coming the downloaded api, provides standard controls for a certificate to be considered as valid. It uses only the certificates store as the source of trusted certificates. The certificate store contains legally valid root certificates. Therefore, in order to work with test certificates you have to define the root of the test certificates as trusted in the certificate validation policy file. You can see section Configuring The Policy at Run-time.
You can also specify the method of revocation control, via either OCSP or CRL. Validation of a certificate requires validation of the all certificates on the certificate chain. Not all of the certificates on the chain is available for OCSP query. So it is not possible to validate a certificate using only OCSP queries. By configuring the validation policy properly, validation operation first tries OCSP and if it is not available then tries CRL control for the certificate revocation check. In this case, the method that must be performed first must be placed before the other in the policy file.
The policy file can be edited after read from the file system. For example, the code below, demonstrates how to add TrustedCertificateFinderFromFileSystem to the validation policy at run-time.
ValidationPolicy POLICY = PolicyReader.readValidationPolicy(new FileInputStream(POLICY_FILE)); //For UEKAE Test Environment, we add our test roots. HashMap<String, Object> parameters = new HashMap<String, Object>(); parameters.put("dizin", "T:\\MA3\\api-cmssignature\\testdata\\support\\UGRootCerts\\"); POLICY.bulmaPolitikasiAl().addTrustedCertificateFinder("tr.gov.tubitak.uekae.esya.api.certificate.validation.find.certificate.trusted.TrustedCertificateFinderFromFileSystem", parameters);
ValidationPolicy POLICY = PolicyReader.readValidationPolicy(POLICY_FILE); //For UEKAE Test Environment, we add our test roots. Dictionary<String, Object> parameters = new Dictionary<String, Object>(); parameters.Add("dizin", "T:\\MA3\\api-cmssignature\\testdata\\support\\UGRootCerts\\"); POLICY.bulmaPolitikasiAl().addTrustedCertificateFinder("tr.gov.tubitak.uekae.esya.api.certificate.validation.find.certificate.trusted.TrustedCertificateFinderFromFileSystem", parameters);
The classes that can be included in the policy file are listed in the table below. In this table, the character “*” in the section where possible values for a paramater are listed denotes the default value. The symbol [O] denotes that the parameter is optional. The XML tags next to each header shows the place where the classes under that header should be in the policy file.
TRUSTED CERTIFICATE CHECKERS <policy><validate><certificate><trustedcertificate> |
|||
---|---|---|---|
CertificateDateChecker | Validates that the validity period in the certificate covers the validation time. | ||
SelfSignatureChecker | Validates that the signature in the certificate is created by the public key in the certificate. | ||
CERTIFICATE SELF CHECKERS <policy><validate><certificate><self> |
|||
CertificateDateChecker | Validates that the validity period in the certificate covers the validation time. | ||
CertificateExtensionChecker | Validates that the extension information in the certificate is compatible with RFC 5280. | ||
PositiveSerialNumberChecker | Validates that the certificate serial number is positive integer. | ||
SignatureAlgConsistencyChecker | Validates thet the signature algorithms in the certificate are matching. | ||
VersionChecker | Validates that the version information in the certificate is compatible with RFC 5280. | ||
QualifiedCertificateChecker | Validates that the certificate has qualified certificate properties. | ||
Parameters | statementoids | Given oids is required in the certificate. In some cases multiple oids are required. You can combine multiple oids with AND or OR relation. Different oids are used in differnet countries. In such cases, oids are combined with OR relation. ( i.e. ”(0.4.0.1862.1.1 AND 2.16.792.1.61.0.1.5070.1.1) OR (4.3.2.1 AND 1.2.3.4)”) | |
CERTIFICATE CHAIN CHECKERS <policy><validate><certificate><issuer> |
|||
BasicConstraintCAChecker | Validates that the basic constraints extension in the issuer certificate is compatible with RFC 5280. | ||
CertificateKeyUsageChecker | Validates that the key usage extension in the issuer certificate is compatible with RFC 5280. | ||
CertificateNameChecker | Validates that the issuer information in the certificate is matching with the subject information in the issuer certificate. | ||
CertificateSignatureChecker | Validates that the signature in the certificate is created by the issuer certificate by cryptographic verification. | ||
KeyIdentifierChecker | Validates that the authority key identifier extension in the certificate is matching with the subject key identifier extension in the issuer certificate. | ||
NameConstraintsChecker | Validates that the relation between subject information in the certificate and the name constraints extension in the issuer certificate is compatible with RFC 5280. | ||
PathLenConstraintChecker | Validates that the path length constraints extension in the issuer certificate is compatible with RFC 5280. | ||
PolicyConstraintsChecker | Validates that the policy constraints extension in the issuer certificate is compatible with RFC 5280. | ||
CERTIFICATE REVOCATION CHECKERS <policy><validate><certificate><revocation> |
|||
RevocationFromCRLChecker | Performs revocation control of a certificate by looking at the corresponding CRL. | ||
Parameters | cevrimdisicalis | [true,false*] Indicates that the validation is performed offline. When specified as True, revocation checker return successful result iven if it can not find any crl. This parameter is defined in order to validate certificates in offline environments where online crls are not available. Must be used with care! |
|
checkAllCRLs | [true,false*] Normally, it is enough to check one valid CRL for the revocation control of a certificate from a crl. In some cases, user may want to check all crls that can be found by the finders. If so, this parameter must be set to true. |
||
devam | [true,false*] If it is true, then the validation process continues to the next crl even if the control for the current crl completed successfully. |
||
RevocationFromOCSPChecker | |||
Parameters | devam | [true,false*] If it is true, then the validation process continues to the next ocsp response even if the control for the current ocsp response completed successfully. |
|
CRL SELF CHECKERS <policy><validate><crl><crlself> |
|||
CRLDateChecker | Validates that the validity period in the crl covers the validation time. | ||
CRLExtensionChecker | Validates that the extension information in the crl is compatible with RFC 5280. | ||
CRL CHAIN CHECKERS <policy><validate><crl><crlissuer> |
|||
CRLKeyUsageChecker | Validates that the key usage extension in the issuer crl certificate is compatible with RFC 5280. | ||
CRLSignatureChecker | Validates that the signature in the crl is created by the crl issuer certificate by cryptographic verification. | ||
DELTA CRL CHECKERS <policy><validate><deltacrl> |
|||
FreshestCRLChecker | Validates that the freshest crl extension in the delta crl is compatible with RFC 5280. | ||
DeltaCRLIndicatorChecker | Validates that the delta crl indicator extension in the delta crl is compatible with RFC 5280. | ||
OCSP RESPONSE CHECKERS <policy><validate><ocsp> |
|||
SigningCertificateChecker | Validates the ocsp response signing certificate. | ||
OCSPSignatureChecker | Validates that the signature in the ocsp response is created by the oscp issuer certificate by cryptographic verification. | ||
ResponseStatusChecker | Validates that the response status information in the ocsp response is valid. | ||
OCSPResponseDateChecker | Validates that the validity period in the ocsp response covers the validation time. |
CERTIFICATE MATCHERS <policy><match><certificate> |
|
---|---|
IssuerSubjectMatcher | Matches the issuer info in the certificate with the subject info in the issuer certificate. |
CRL MATCHERS <policy><match><certificate> |
|
CRLDistributionPointMatcher | Matches the CRL Distribution Points (CDP) extension in the certificate and the Issuing Distribution Point (IDP) extension in the CRL. |
CRLDistributionPointOnlyContainsMatcher | Matches “onlyContains” feautres in the Issuing Distribution Point (IDP) extension in the CRL and Basic Constraints extension in the certificate. |
CRLIssuerMatcher | Matches the issuer info in the CRL and the issuer info in the certificate. |
CRLKeyIDMatcher | Matches the authority key identifier extension in the crl and the authority key identifier extension in the certificate. |
Delta CRL MATCHERS<policy><match><certificate> |
|
BaseCRLNumberMatcher | Matches the Base CRL Number extension in the delta crl with the CRL Number extension in the crl. |
CRLNumberMatcher | Matches the CRL Number extension in the delta crl with the CRL Number extension in the crl, by checking the former is greater than the latter. |
DeltaCRLIssuerMatcher | Matches the issuer information in the delta crl with the issuer information in the base crl. |
ScopeMatcher | Matches the Issuing Distribution Point extension in the delta crl with the Issuing Distribution Point extension in the vase crl. |
OCSP RESPONSE MATCHERS <policy><match><ocsp> |
|
CertIDOCSPResponseMatcher | Matches the certificate with the ocsp response by looking at the Cert ID field in the ocsp response. |
CROSS CERTIFICATE MATCHERS <policy><match><crosscertificate> |
|
PublicKeyMatcher | Matches the public key in the issuer certificate with the public key in the cross certificate. |
SKIMatcher | Matches the Subject Key Identifier extension in the issuer certificate with the Subject Key Identifier extension in the cross certificate. |
SubjectMatcher | Matches the subject information in the issuer certificate with the subject information in the cross certificate. |
TRUSTED CERTFICATE FINDERS<policy> <find><trustedcertificate> |
|||
---|---|---|---|
TrustedCertificateFinderFromECertStore | Finds the issuer certificates stored in the local certificate store. | ||
Parameters | securitylevel | [PERSONAL*, ORGANIZATIONAL, LEGAL] Specifies the trust level of the found certificates. For personally defined certificates PERSONAL is used. ORGANIZATIONAL is used for trusting the certificates defined by the organization. LEGAL is used when only legally trusted certificates are trusted. |
|
storepath [O] | Specifies the location of the certificate store in the file system. | ||
TrustedCertificateFinderFromFileSystem |
||
Parameters | dizin | Folder address | |
TrustedCertificateFinderFromXml | Finds issuer certificates in an XML file at the given URL. | ||
Parameters | storepath [O] | URL address | |
CERTIFICATE FINDERS <policy><find><certificate> |
|||
---|---|---|---|
CertificateFinderFromECertStore | Finds the certificates stored in the local certificate store | ||
Parameters | storepath [0] | Specifies the location of the certificate store in the file system. | |
CertificateFinderFromFile | Finds the certificate in the file system. | ||
Parameters | dosyayolu | File address | |
CertificateFinderFromXml | Finds the certificate in an XML file at the given URL. | ||
Parameters | storepath [O] | URL address | |
CertificateFinderFromHTTP | Finds the issuer certificate by looking at the HTTP address in the Authority Info Access extension in the certificate. | ||
CertificateFinderFromLDAP | Finds the issuer certificate by looking at the LDAP address in the Authority Info Access extension in the certificate. | ||
CRL FINDERS <policy><validate><certificate><revocation><find> |
|||
CRLFinderFromECertStore | Finds the crls stored in the local certificate store. | ||
Parameters | storepath [0] | Specifies the location of the certificate store in the file system. | |
getactivecrl | [true,false*] For the certificate validation bo be more certain, the crls that are published after the validation time must be used. But in some cases, the new crl to be published may not be waited. In such cases, this parameter must be set to true. |
||
CRLFinderFromFile | Finds the crl in the file system. | ||
Parameters | dosyayolu | File address | |
CRLFinderFromHTTP | Finds the crl by looking at the HTTP address in the CRL Distribution Points extension in the certificate. | ||
CRLFinderFromLDAP | Finds the crl by looking at the LDAP address in the CRL Distribution Points extension in the certificate. | ||
OCSP RESPONSE FINDERS <policy><validate><certificate><revocation><find> |
|||
OCSPResponseFinderFromECertStore | Finds the ocsp reponses stored in the local certificate store. | ||
Parameters | storepath [0] | Specifies the location of the certificate store in the file system. | |
OCSPResponseFinderFromAIA | Finds the crl by looking at the OCSP server address in the Authority Information Access extension in the certificate. | ||
DELTA CRL FINDERS <find><deltacrl> |
|||
DeltaCRLFinderFromECertStore | Finds the delta crls stored in the local certificate store. | ||
Parameters | storepath [0] | Specifies the location of the certificate store in the file system. | |
DeltaCRLFinderFromFile | Finds the delta crl in the file system. | ||
Parameters | dosyayolu | File address | |
CROSS CERTIFICATE FINDERS <find><crosscertificate> |
|||
CrossCertificateFinderFromECertStore | Finds the delta crls stored in the local certificate store. | ||
Parameters | storepath [0] | Specifies the location of the certificate store in the file system. | |
CrossCertificateFinderFromFile | Finds the cross certificates in the file system. | ||
Parameters | dosyayolu | File address |
SAVERS<policy><save> |
|||
---|---|---|---|
CertStoreCertificateSaver | Saves the certificates found during the validation into the local certificate store. | ||
Parameters | storepath [O] | Specifies the location of the certificate store in the file system. | |
CertStoreCRLSaver | Saves the crls found during the validation into the local certificate store. | ||
Parameters | storepath [O] | Specifies the location of the certificate store in the file system. | |
CertStoreOCSPResponseSaver | Saves the ocsp responses found during the validation into the local certificate store. | ||
Parameters | storepath [O] | Specifies the location of the certificate store in the file system. |