New CertificateRevokedException class in JDK 7

There is a new CertificateRevocationException class in JDK 7 in the java.security.cert package that indicates that an X.509 certificate is revoked and also allows you to determine additional information such as the reason the certificate has been revoked and when it was revoked.  The getRevocationReason method returns a CRLReason, which is a new enum class that enumerates the different reasons an X.509 certificate can be revoked, such as compromise of the private key. In JDK 7, The Sun PKIX CertPathValidator service provider implementation has been enhanced to throw this exception. Here's an example of how your application may use this new exception class:

CertPathValidator cpv = CertPathValidator.getInstance("PKIX", "Sun");
try {
    CertPathValidatorResult cpvr = cpv.validate(path, params);
} catch (CertPathValidatorException cpve) {
    if (cpve.getCause() instanceof CertificateRevokedException) {
        CertificateRevokedExcepion cre = (CertificateRevokedException) cpve.getCause();
        System.err.println("Certificate  revoked on " + cre.getRevocationDate());
        System.err.println("reason  for revocation: " + cre.getCRLReason());
    }
}
Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Sean Mullan

Search

Top Tags
Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today