AnsweredAssumed Answered

Setting validity interval in CryptoJ

Question asked by Y4pY4p8RBmkanhWdB8Quw73Bs9eIwlFOS6tNcvR1ios= on Jun 3, 2016

We are trying to set a validity interval for a certtemplate, using Crypto-J,  which is something that used to work proprly in Cert-J, but we are getting an exception while creating a request using that template. It looks to me like a bug in the ASN.1 encoding, but maybe we are doing something wrong.


When the code bellow is executed:


Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTCTime"));


Date fromDate;

Date toDate;


cal.setTime(new Date());

cal.add(Calendar.DATE, - (1));

fromDate = cal.getTime();


cal.setTime(new Date());

cal.add(Calendar.DATE, 365);

toDate = cal.getTime();


template.setValidity(fromDate, toDate);


CRMFParameterSpec params = new CRMFParameterSpec(BigInteger.ZERO, template, pop);

CertRequestFactory factory = CertRequestFactory.getInstance("CRMF");


CertRequest req = factory.generateRequest(params);


We get this exception:


Exception in thread "main" com.rsa.cryptoj.c.b: Value is of incorrect type. (expected: [0] EXPLICIT CHOICE {

    utcTime    UTCTime,

    generalTime    GeneralizedTime

}, was: [UNIVERSAL 23] IMPLICIT VisibleString)


Any idea what could be wrong?



Yamian Quintero