public Certificate add(X509Certificate cert) {
        final Certificate db;
        try {
            db = Certificate.from(cert);
        } catch (CertificateEncodingException e) {
            logger.error("Encoding error in certificate", e);
            throw new RuntimeException("Encoding error in certificate", e);
        }

        try {
            // Special case for first CSCA certificate for this document type
            if (repository.countByDocumentType(db.getDocumentType()) == 0) {
                cert.verify(cert.getPublicKey());
                logger.warn("Added first CSCA certificate for {}, set trusted flag manually", db.getDocumentType());
            } else {
                verify(cert, allowAddingExpired ? cert.getNotAfter() : null);
            }
        } catch (GeneralSecurityException | VerificationException e) {
            logger.error(
                String.format("Could not verify certificate of %s issued by %s",
                    cert.getSubjectX500Principal(), cert.getIssuerX500Principal()
                ), e
            );
            throw new BadRequestException("Could not verify certificate", e);
        }
        return repository.saveAndFlush(db);
    }
@Test
    public void shouldAllowToAddCRL() throws Exception {
        certificateRepo.saveAndFlush(loadCertificate("rdw/02.cer", true));
        service.add(readCRL("rdw/02.crl"));
    }