public CA(String dn) throws Exception { Calendar c = new GregorianCalendar(); Date now = c.getTime(); c.add(Calendar.YEAR, 5); Date expires = c.getTime(); KeyPair pair = KeyUtil.generateRSAKeyPair512(); this.key = pair.getPrivate(); cert = CertUtil.generateCACertificate(new X509Name(dn), now, expires, pair); }
public Credential createIdentityCertificate(String id) throws Exception { String dn = getCertificate().getSubjectDN().getName(); int index = dn.indexOf("CN="); dn = dn.substring(0, index + 3) + id; KeyPair pair = KeyUtil.generateRSAKeyPair512(); Date now = new Date(); Date end = getCertificate().getNotAfter(); return new Credential( CertUtil.generateCertificate( new X509Name(dn), now, end, pair.getPublic(), getCertificate(), getPrivateKey(), null), pair.getPrivate()); }
public CA(String dn, Date start, Date expires) throws Exception { KeyPair pair = KeyUtil.generateRSAKeyPair512(); this.key = pair.getPrivate(); cert = CertUtil.generateCACertificate(new X509Name(dn), start, expires, pair); }