问题描述
您好,我正在尝试使用 Google KMS 和 Scala 解密值。
Scala 版本 2.11.12
这是我的代码
val fileInputStream = new FileInputStream("<service account>")
val credential = GoogleCredentials.fromStream(fileInputStream)
val keyManagementServiceSettings: KeyManagementServiceSettings = KeyManagementServiceSettings.newBuilder().setCredentialsProvider(FixedCredentialsProvider.create(credential)).build()
val clientKms = KeyManagementServiceClient.create(keyManagementServiceSettings)
// get key name
val project_id = ""
val location_id = ""
val key_ring_id = ""
val key_id = ""
val keyName = CryptoKeyName.newBuilder().setProject(project_id).setLocation(location_id).setKeyRing(key_ring_id).setCryptoKey(key_id).build()
// get cipherByte
val storage = StorageOptions.newBuilder.setCredentials(credential).build.getService
val bucketName = "..."
val bucket = storage.get(bucketName)
val blob = bucket.get(key_blob)
val cipher = blob.getContent()
val cipherByte = ByteString.copyFrom(cipher)
//decrypt and hang ...
val plaintext = clientKms.decrypt(keyName,cipherByte)
这是我的依赖项
io.grpc:grpc-netty:1.36.0
io.grpc:grpc-core:1.36.0
io.netty:netty-codec-http2:4.1.60.Final
com.google.guava:guava:30.0-jre
io.grpc:grpc-netty-shaded:1.36.0
google-cloud-kms-1.40.2
当我尝试将 gRpc 更改为 okhttp 时
io.grpc:grpc-okhttp:1.36.0
我遇到了这个错误
Caused by: io.grpc.StatusRuntimeException: INTERNAL: Panic! This is a bug!
at io.grpc.Status.asRuntimeException(Status.java:535)
... 17 more
Caused by: java.lang.NoSuchFieldError: STOPWATCH_supplier
at io.grpc.okhttp.OkHttpClientTransport.<init>(OkHttpClientTransport.java:260)
at io.grpc.okhttp.OkHttpChannelBuilder$OkHttpTransportFactory.newClientTransport(OkHttpChannelBuilder.java:721)
at io.grpc.internal.CallCredentialsApplyingTransportFactory.newClientTransport(CallCredentialsApplyingTransportFactory.java:57)
at io.grpc.internal.InternalSubchannel.startNewTransport(InternalSubchannel.java:253)
at io.grpc.internal.InternalSubchannel.access$400(InternalSubchannel.java:65)
at io.grpc.internal.InternalSubchannel$2.run(InternalSubchannel.java:200)
at io.grpc.SynchronizationContext.drain(SynchronizationContext.java:95)
at io.grpc.SynchronizationContext.execute(SynchronizationContext.java:127)
at io.grpc.internal.ManagedChannelImpl$NameResolverListener.onResult(ManagedChannelImpl.java:1815)
at io.grpc.internal.DnsNameResolver$Resolve.run(DnsNameResolver.java:333)
... 3 more
Suppressed: com.google.api.gax.rpc.AsyncTaskException: Asynchronous task Failed
at com.google.api.gax.rpc.ApiExceptions.callAndTranslateApiException(ApiExceptions.java:57)
at com.google.api.gax.rpc.UnaryCallable.call(UnaryCallable.java:112)
at com.google.cloud.kms.v1.KeyManagementServiceClient.decrypt(KeyManagementServiceClient.java:2624)
at com.google.cloud.kms.v1.KeyManagementServiceClient.decrypt(KeyManagementServiceClient.java:2567)
有什么建议吗?
感谢您的回复。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)