public CertificateAuthorityInformation create(final String organization, final Integer daysValid) throws CACreationException, KeyStoreStorageException, KeyStoreException {
        final Duration certificateValidity = Duration.ofDays(daysValid == null || daysValid == 0 ? CaKeystore.DEFAULT_SELFSIGNED_VALIDITY_DAYS : daysValid);
        KeyStore keyStore = CAKeyPair.create(organization, passwordSecret.toCharArray(), certificateValidity).toKeyStore();
        writeToDatabase(keyStore);
        LOG.debug("Generated a new CA.");
        triggerCaChangedEvent();
        return get().orElseThrow(() -> new IllegalStateException("Failed to obtain CA information, but a CA has been just created. Inconsistent state!"));
    }
@Test
    void testCreate() throws KeyStoreStorageException, KeyStoreException, CACreationException {
        final Configuration configuration = Mockito.mock(Configuration.class);
        final String password = RandomStringUtils.randomAlphanumeric(20);
        final EncryptedValueService encryptionService = new EncryptedValueService(password);
        final InMemoryClusterConfigService clusterConfigService = new InMemoryClusterConfigService();
        final CaPersistenceService service = new CaPersistenceService(configuration, password, Mockito.mock(ClusterEventBus.class), clusterConfigService, encryptionService);

        service.create("my-org", 30);

        Assertions.assertThat(service.loadKeyStore())
                .isPresent()
                .hasValueSatisfying(k -> {
                    Assertions.assertThat(k.password()).isEqualTo(password);
                    try {
                        Assertions.assertThat(k.keyStore().getCertificate("ca")).isNotNull();
                    } catch (KeyStoreException e) {
                        throw new RuntimeException(e);
                    }
                });

        service.startOver();

        Assertions.assertThat(service.loadKeyStore()).isEmpty();
    }