updatePropertyOnServer(CmpConfiguration.CONFIG_RA_NAMEGENERATIONSCHEME, "DN");
updatePropertyOnServer(CmpConfiguration.CONFIG_RA_NAMEGENERATIONPARAMS, "CN");
CryptoProviderTools.installBCProvider();
// Try to use AdminCA1 if it exists
final CAInfo adminca1;
adminca1 = caAdminSessionRemote.getCAInfo(admin, "AdminCA1");
if (adminca1 == null) {
final Collection<Integer> caids;
caids = caSession.getAvailableCAs(admin);
final Iterator<Integer> iter = caids.iterator();
int tmp = 0;
while (iter.hasNext()) {
tmp = iter.next().intValue();
}
caid = tmp;
} else {
caid = adminca1.getCAId();
}
if (caid == 0) {
assertTrue("No active CA! Must have at least one active CA to run tests!", false);
}
final CAInfo cainfo;
cainfo = caAdminSessionRemote.getCAInfo(admin, caid);
Collection<Certificate> certs = cainfo.getCertificateChain();
if (certs.size() > 0) {
Iterator<Certificate> certiter = certs.iterator();
Certificate cert = certiter.next();
String subject = CertTools.getSubjectDN(cert);
if (StringUtils.equals(subject, cainfo.getSubjectDN())) {
// Make sure we have a BC certificate
try {
cacert = (X509Certificate) CertTools.getCertfromByteArray(cert.getEncoded());
} catch (Exception e) {
throw new Error(e);