3
3
import static ee .carlrobert .codegpt .credentials .CredentialsStore .getCredential ;
4
4
5
5
import com .intellij .openapi .application .ApplicationManager ;
6
+ import com .intellij .util .net .ssl .CertificateManager ;
6
7
import ee .carlrobert .codegpt .credentials .CredentialsStore .CredentialKey ;
7
8
import ee .carlrobert .codegpt .settings .advanced .AdvancedSettings ;
8
9
import ee .carlrobert .codegpt .settings .service .anthropic .AnthropicSettings ;
21
22
import java .net .InetSocketAddress ;
22
23
import java .net .Proxy ;
23
24
import java .util .concurrent .TimeUnit ;
25
+ import javax .net .ssl .X509TrustManager ;
24
26
import okhttp3 .Credentials ;
25
27
import okhttp3 .OkHttpClient ;
26
28
@@ -39,10 +41,12 @@ public static OpenAIClient getOpenAIClient() {
39
41
}
40
42
41
43
public static ClaudeClient getClaudeClient () {
42
- return new ClaudeClient (
43
- getCredential (CredentialKey .AnthropicApiKey .INSTANCE ),
44
- AnthropicSettings .getCurrentState ().getApiVersion (),
45
- getDefaultClientBuilder ());
44
+ var builder = new ClaudeClient .Builder (getCredential (CredentialKey .AnthropicApiKey .INSTANCE ),
45
+ AnthropicSettings .getCurrentState ().getApiVersion ());
46
+ if (AnthropicSettings .getCurrentState ().hasCustomBaseHost ()) {
47
+ builder .setHost (AnthropicSettings .getCurrentState ().getBaseHost ());
48
+ }
49
+ return builder .build (getDefaultClientBuilder ());
46
50
}
47
51
48
52
public static AzureClient getAzureClient () {
@@ -96,6 +100,9 @@ public static GoogleClient getGoogleClient() {
96
100
97
101
public static OkHttpClient .Builder getDefaultClientBuilder () {
98
102
OkHttpClient .Builder builder = new OkHttpClient .Builder ();
103
+ CertificateManager certificateManager = CertificateManager .getInstance ();
104
+ X509TrustManager trustManager = certificateManager .getTrustManager ();
105
+ builder .sslSocketFactory (certificateManager .getSslContext ().getSocketFactory (), trustManager );
99
106
var advancedSettings = AdvancedSettings .getCurrentState ();
100
107
var proxyHost = advancedSettings .getProxyHost ();
101
108
var proxyPort = advancedSettings .getProxyPort ();
0 commit comments