Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to trust all certificates #134

Open
Sword-zhj opened this issue Nov 4, 2022 · 4 comments
Open

How to trust all certificates #134

Sword-zhj opened this issue Nov 4, 2022 · 4 comments

Comments

@Sword-zhj
Copy link

how can i trust all certificates when use @RetrofitClient.
Exception:
RetrofitIOException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

@chenxinxing
Copy link

同问。

@demidroid
Copy link

同问

@kinggua
Copy link

kinggua commented Jun 29, 2023

@slf4j
@component
public class CustomSourceOkHttpClientRegistrar implements SourceOkHttpClientRegistrar {

@Override
public void register(SourceOkHttpClientRegistry registry) {

    // add testSourceOkHttpClient
    registry.register("testSourceOkHttpClient", new OkHttpClient.Builder()
          // ignore ssl
           .sslSocketFactory(sslSocketFactory(), x509TrustManager())
            .connectTimeout(Duration.ofSeconds(3))
            .writeTimeout(Duration.ofSeconds(3))
            .readTimeout(Duration.ofSeconds(3))
            .addInterceptor(chain -> {
                log.info("============use testSourceOkHttpClient=============");
                return chain.proceed(chain.request());
            })
            .build());
}

}

//

@chentianming11
Copy link
Collaborator

custom okhttpClient

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants