public static TrustManager[] trustManager(boolean needAuth, String trustCertPath) {
        if (needAuth) {
            try {
                return trustCertPath == null ? null : buildSecureTrustManager(trustCertPath);
            } catch (SSLException e) {
                LOGGER.warn("degrade trust manager as build failed, " + "will trust all certs.");
                return trustAll;
            }
        } else {
            return trustAll;
        }
    }
@Test
    void testTrustManagerSuccess() throws CertificateException {
        URL url = SelfTrustManagerTest.class.getClassLoader().getResource("test-tls-cert.pem");
        String path = url.getPath();
        TrustManager[] actual = SelfTrustManager.trustManager(true, path);
        assertNotNull(actual);
        assertEquals(1, actual.length);
        assertTrue(actual[0] instanceof X509TrustManager);
        assertFalse(actual[0].getClass().getCanonicalName().startsWith("com.alibaba.nacos"));
        X509TrustManager x509TrustManager = (X509TrustManager) actual[0];
        X509Certificate[] certificates = x509TrustManager.getAcceptedIssuers();
        assertNotNull(certificates);
        x509TrustManager.checkClientTrusted(certificates, "a");
        x509TrustManager.checkServerTrusted(certificates, "b");
    }