class InternalTlsCertificateService {

    public void generateInternalTlsKeyAndCertificate() throws InterruptedException {
        try {
            externalProcessRunner.executeAndThrowOnFailure(generateCertScriptPath,
                    generateCertScriptArgs.split("\\s+"));
        } catch (ProcessNotExecutableException | ProcessFailedException e) {
            log.error("Failed to generate internal TLS key and cert", e);
            throw new DeviationAwareRuntimeException(e, new ErrorDeviation(KEY_CERT_GENERATION_FAILED));
        }
        // audit log hash of generated cert
        X509Certificate generatedCert = internalTlsCertificateRepository.getInternalTlsCertificate();
        auditDataHelper.putCertificateHash(generatedCert);
    }

    @Autowired public  InternalTlsCertificateService(InternalTlsCertificateRepository internalTlsCertificateRepository,
            ExternalProcessRunner externalProcessRunner,
            @Value("${script.generate-certificate.path}") String generateCertScriptPath,
            @Value("${script.generate-certificate.args}") String generateCertScriptArgs,
            AuditDataHelper auditDataHelper);

}