mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-05-20 09:24:08 +00:00
fix: update gRPC client with SSL support
This commit is contained in:
parent
90a0f91d56
commit
3e3d605ab0
1 changed files with 8 additions and 1 deletions
|
|
@ -11,6 +11,7 @@ import com.intellij.openapi.components.service
|
|||
import com.intellij.openapi.diagnostic.thisLogger
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.util.net.ssl.CertificateManager
|
||||
import com.jetbrains.rd.util.UUID
|
||||
import ee.carlrobert.codegpt.codecompletions.CompletionProgressNotifier
|
||||
import ee.carlrobert.codegpt.credentials.CredentialsStore
|
||||
|
|
@ -25,6 +26,7 @@ import ee.carlrobert.service.NextEditRequest
|
|||
import ee.carlrobert.service.NextEditResponse
|
||||
import ee.carlrobert.service.NextEditServiceImplGrpc
|
||||
import io.grpc.*
|
||||
import io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts
|
||||
import io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder
|
||||
import io.grpc.stub.StreamObserver
|
||||
import java.util.concurrent.Executor
|
||||
|
|
@ -50,7 +52,12 @@ class GrpcClientService(private val project: Project) : Disposable {
|
|||
private fun ensureConnection() {
|
||||
if (channel == null || channel?.isShutdown == true) {
|
||||
try {
|
||||
channel = NettyChannelBuilder.forAddress(HOST, PORT).build()
|
||||
channel = NettyChannelBuilder.forAddress(HOST, PORT)
|
||||
.useTransportSecurity()
|
||||
.sslContext(GrpcSslContexts.forClient()
|
||||
.trustManager(CertificateManager.getInstance().trustManager)
|
||||
.build())
|
||||
.build()
|
||||
stub = NextEditServiceImplGrpc.newStub(channel)
|
||||
.withCallCredentials(
|
||||
ApiKeyCredentials(CredentialsStore.getCredential(CodeGptApiKey) ?: "")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue