protected CertPair generateCert() {
        if (certPair != null && !certPair.isExpire()) {
            return certPair;
        }
        synchronized (this) {
            if (certPair == null || certPair.isExpire()) {
                try {
                    logger.info("Try to generate cert from Dubbo Certificate Authority.");
                    CertPair certFromRemote = refreshCert();
                    if (certFromRemote != null) {
                        certPair = certFromRemote;
                    } else {
                        logger.error(
                                CONFIG_SSL_CERT_GENERATE_FAILED,
                                "",
                                "",
                                "Generate Cert from Dubbo Certificate Authority failed.");
                    }
                } catch (Exception e) {
                    logger.error(REGISTRY_FAILED_GENERATE_CERT_ISTIO, "", "", "Generate Cert from Istio failed.", e);
                }
            }
        }
        return certPair;
    }
@Test
    void testGenerateCert() {
        FrameworkModel frameworkModel = new FrameworkModel();

        AtomicBoolean exception = new AtomicBoolean(false);
        AtomicReference<CertPair> certPairReference = new AtomicReference<>();
        DubboCertManager certManager = new DubboCertManager(frameworkModel) {
            @Override
            protected CertPair refreshCert() throws IOException {
                if (exception.get()) {
                    throw new IOException("test");
                }
                return certPairReference.get();
            }
        };

        CertPair certPair = new CertPair("", "", "", Long.MAX_VALUE);
        certPairReference.set(certPair);

        Assertions.assertEquals(certPair, certManager.generateCert());

        certManager.certPair = new CertPair("", "", "", Long.MAX_VALUE - 10000);
        Assertions.assertEquals(new CertPair("", "", "", Long.MAX_VALUE - 10000), certManager.generateCert());

        certManager.certPair = new CertPair("", "", "", 0);
        Assertions.assertEquals(certPair, certManager.generateCert());

        certManager.certPair = new CertPair("", "", "", 0);
        certPairReference.set(null);
        Assertions.assertEquals(new CertPair("", "", "", 0), certManager.generateCert());

        exception.set(true);
        Assertions.assertEquals(new CertPair("", "", "", 0), certManager.generateCert());

        frameworkModel.destroy();
    }