We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The error I get:
io.grpc.ManagedChannelRegistry$ProviderNotFoundException: io.grpc.okhttp.OkHttpChannelProvider: Unable to load private key: Neither RSA nor EC worked
I am trying to load pass the certificate as a string instead of reading a file, because it is dynamic. In order to establish a gRPC connection.
class GrpcModule( private val certificateRoot: String, private val certificateStr: String, private val privateKeyStr: String, ) { val channel: ManagedChannel by lazy { val pk: InputStream = privateKeyStr.byteInputStream() val cu: InputStream = certificateStr.byteInputStream() val cr: InputStream = certificateRoot.byteInputStream() val credentials = TlsChannelCredentials.newBuilder() .keyManager( pk, cu ) .trustManager(cr) .build() Grpc.newChannelBuilder("localhost:50001", credentials) .executor(Dispatchers.IO.asExecutor()) .build() } private val stub = ReceivingGrpcKt.ReceivingCoroutineStub(channel) suspend fun checkId(id: String) = try { val request = checkRequest { this.id = id } val response = stub.check(request) Log.d("Grpc", "Success --- $response") } catch (e: Exception) { Log.d("Grpc", "Error --- $e") } fun close() { channel.shutdownNow() } }
And I'll be calling it from a ReactNative module, like so:
class Grpc(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) { override fun getName() = "Grpc" @ReactMethod fun test() { var g = GrpcModule( """ -----BEGIN CERTIFICATE----- -----END CERTIFICATE----- """.trimIndent(), """ -----BEGIN CERTIFICATE----- -----END CERTIFICATE----- """.trimIndent(), """ -----BEGIN PRIVATE KEY----- -----END PRIVATE KEY----- """.trimIndent(), ) Log.d("Grpc", "--- $g") runBlocking { g.checkId("222") } g.close() } }
What am I doing wrong here and how can I fix this?
Is this even the right way to go about it?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The error I get:
I am trying to load pass the certificate as a string instead of reading a file, because it is dynamic. In order to establish a gRPC connection.
And I'll be calling it from a ReactNative module, like so:
What am I doing wrong here and how can I fix this?
Is this even the right way to go about it?
The text was updated successfully, but these errors were encountered: