use of sun.security.x509.CertificateValidity in project OpenAttestation by OpenAttestation.
the class X509Builder method valid.
public X509Builder valid(Date from, Date to) {
try {
certificateValidity = new CertificateValidity(from, to);
// CertificateException, IOException
info.set(X509CertInfo.VALIDITY, certificateValidity);
} catch (Exception e) {
fault(e, "valid(%s,%s)", from == null ? "null" : from.toString(), to == null ? "null" : to.toString());
}
return this;
}
use of sun.security.x509.CertificateValidity in project jdk8u_jdk by JetBrains.
the class SimpleSigner method getSelfCert.
private X509Certificate getSelfCert() throws Exception {
long validity = 1000;
X509CertImpl certLocal;
Date firstDate, lastDate;
firstDate = new Date();
lastDate = new Date();
lastDate.setTime(lastDate.getTime() + validity + 1000);
CertificateValidity interval = new CertificateValidity(firstDate, lastDate);
X509CertInfo info = new X509CertInfo();
// Add all mandatory attributes
info.set(X509CertInfo.VERSION, new CertificateVersion(CertificateVersion.V1));
info.set(X509CertInfo.SERIAL_NUMBER, new CertificateSerialNumber((int) (firstDate.getTime() / 1000)));
info.set(X509CertInfo.ALGORITHM_ID, new CertificateAlgorithmId(algId));
info.set(X509CertInfo.SUBJECT, agent);
info.set(X509CertInfo.KEY, new CertificateX509Key(publicKey));
info.set(X509CertInfo.VALIDITY, interval);
info.set(X509CertInfo.ISSUER, agent);
certLocal = new X509CertImpl(info);
certLocal.sign(privateKey, algId.getName());
return certLocal;
}
Aggregations