public synchronized void connect(CertConfig certConfig) {
        if (channel != null) {
            logger.error(INTERNAL_ERROR, "", "", "Dubbo Cert Authority server is already connected.");
            return;
        }
        if (certConfig == null) {
            // No cert config, return
            return;
        }
        if (StringUtils.isEmpty(certConfig.getRemoteAddress())) {
            // No remote address configured, return
            return;
        }
        if (StringUtils.isNotEmpty(certConfig.getEnvType())
                && !"Kubernetes".equalsIgnoreCase(certConfig.getEnvType())) {
            throw new IllegalArgumentException("Only support Kubernetes env now.");
        }
        // Create gRPC connection
        connect0(certConfig);

        this.certConfig = certConfig;

        // Try to generate cert from remote
        generateCert();
        // Schedule refresh task
        scheduleRefresh();
    }
@Test
    void test1() {
        FrameworkModel frameworkModel = new FrameworkModel();
        DubboCertManager certManager = new DubboCertManager(frameworkModel) {
            @Override
            protected void connect0(CertConfig certConfig) {
                Assertions.assertEquals("127.0.0.1:30060", certConfig.getRemoteAddress());
                Assertions.assertEquals("caCertPath", certConfig.getCaCertPath());
            }

            @Override
            protected CertPair generateCert() {
                return null;
            }

            @Override
            protected void scheduleRefresh() {}
        };
        certManager.connect(new CertConfig("127.0.0.1:30060", null, "caCertPath", "oidc"));
        Assertions.assertEquals(new CertConfig("127.0.0.1:30060", null, "caCertPath", "oidc"), certManager.certConfig);

        certManager.connect(new CertConfig("127.0.0.1:30060", "Kubernetes", "caCertPath", "oidc123"));
        Assertions.assertEquals(
                new CertConfig("127.0.0.1:30060", "Kubernetes", "caCertPath", "oidc123"), certManager.certConfig);

        certManager.connect(new CertConfig("127.0.0.1:30060", "kubernetes", "caCertPath", "oidc345"));
        Assertions.assertEquals(
                new CertConfig("127.0.0.1:30060", "kubernetes", "caCertPath", "oidc345"), certManager.certConfig);

        CertConfig certConfig = new CertConfig("127.0.0.1:30060", "vm", "caCertPath", "oidc");
        Assertions.assertThrows(IllegalArgumentException.class, () -> certManager.connect(certConfig));
        Assertions.assertEquals(
                new CertConfig("127.0.0.1:30060", "kubernetes", "caCertPath", "oidc345"), certManager.certConfig);

        certManager.connect(null);
        Assertions.assertEquals(
                new CertConfig("127.0.0.1:30060", "kubernetes", "caCertPath", "oidc345"), certManager.certConfig);

        certManager.connect(new CertConfig(null, null, null, null));
        Assertions.assertEquals(
                new CertConfig("127.0.0.1:30060", "kubernetes", "caCertPath", "oidc345"), certManager.certConfig);

        certManager.channel = Mockito.mock(Channel.class);
        certManager.connect(new CertConfig("error", null, "error", "error"));
        Assertions.assertEquals(
                new CertConfig("127.0.0.1:30060", "kubernetes", "caCertPath", "oidc345"), certManager.certConfig);

        frameworkModel.destroy();
    }