Quantcast
Channel: Active questions tagged header - Stack Overflow
Viewing all articles
Browse latest Browse all 649

received UNAVAILABLE during grpc call: Trust anchor for certification not found

$
0
0

i have the following code for grpc:

val port = 9090val metadata = Metadata()metadata.put(Metadata.Key.of("Authorization", Metadata.ASCII_STRING_MARSHALLER), "Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJCTzdIZWwwSkRpc0YxR1JWd21oZmRxanpJZFdLS1VlX3htWEVkTndsNzZ3In0.eyJleHAiOjE3MTUxNTg0NzksImlhdCI6MTcxNTE1NjY3OSwianRpIjoiZDExMTYwZDEtNGYxZS00ZTgxLTg0NDQtMjQwMjZjMzg5ODM1IiwiaXNzIjoiaHR0cHM6Ly9hdXRoLnYyLmZyaWRheS5mYXN0ZWsucGgvcmVhbG1zL0Zhc3Rlay1BdXRoIiwic3ViIjoiM2ZkMDJlZTEtZTk5Ni00N2QzLWEwM2QtMGIyYWVhMmM1MjE5IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiSzI1ODIzNzMwMDAyOSIsInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJJbWFnZSBQcm9jZXNzaW5nIEFjY291bnQiLCJQYXJ0bmVyIFNlcnZpY2UgQWNjb3VudCJdfSwic2NvcGUiOiIiLCJjbGllbnRIb3N0IjoiMzUuMjI5LjIzMi40NSIsImNsaWVudElkIjoiSzI1ODIzNzMwMDAyOSIsImNsaWVudEFkZHJlc3MiOiIzNS4yMjkuMjMyLjQ1In0.P3uIa7S36cLN3w49yeeyf0Ddd5nibQuE_nzdJzBOQewjIBwqGPTsPHvtsa59Ldnc_enYbjxzURoJ5ho-FeQZwuIEb2iM5yB_UrzPDFgZbsUBwNH3-Efdv1W-7lS-4XLne4BmT-7fP-H6EFjVTD8pDArSeX53O6fXn79VJJaEFYpZ7CGqEc2NoBmi8dhKpzcJ7ii1-kkPm3sSOiNwjDannXTXy8hA-INuAyE_dZu7souHN_IJL6e7yw8ueeo-eXDPwjB9QxAR09aRfFNGkuzgghPzeIsJAeaf8GLRdNDzF4YB6klaCPOM19-FNuD7P3pdLfAKqD-Dxa2jPl8jjODRow")metadata.put(Metadata.Key.of("txn-mgr-flag", Metadata.ASCII_STRING_MARSHALLER), "false")val channel = ManagedChannelBuilder            .intercept(MetadataUtils.newAttachHeadersInterceptor(metadata))            .forAddress("grpc.friday.fastek.ph", port)            .useTransportSecurity()            .build()try {val client = FastekBeepClient(channel)client.stmBalance()

i added the headers this way...

val metadata = io.grpc.Metadata()metadata.put(Metadata.Key.of("authorization", Metadata.ASCII_STRING_MARSHALLER),"Bearer token...")

then call the rpc method this way..

client.stmBalance(intialRequest))

take note that i needed to add authorization as header as it was needed

Im still getting UNAVAILABLE status but when i tried it on postman it was working..

Stacktrace:

2024-05-08 11:43:44.650 32644-32644 AndroidRuntime         ph.skybridge.android                 E  FATAL EXCEPTION: mainProcess: ph.skybridge.android, PID: 32644io.grpc.StatusException: UNAVAILABLE    at io.grpc.Status.asException(Status.java:548)    at io.grpc.kotlin.ClientCalls$rpcImpl$1$1$1.onClose(ClientCalls.kt:300)    at io.grpc.internal.DelayedClientCall$DelayedListener$3.run(DelayedClientCall.java:489)    at io.grpc.internal.DelayedClientCall$DelayedListener.delayOrExecute(DelayedClientCall.java:453)    at io.grpc.internal.DelayedClientCall$DelayedListener.onClose(DelayedClientCall.java:486)    at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:564)    at io.grpc.internal.ClientCallImpl.access$100(ClientCallImpl.java:72)    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:729)    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:710)    at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)    at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)    at java.lang.Thread.run(Thread.java:761)    Suppressed:kotlinx.coroutines.internal.DiagnosticCoroutineContextException:[StandaloneCoroutine{Cancelling}@d8394aa, Dispatchers.Main]Caused by: javax.net.ssl.SSLHandshakeException:java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.    at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:361)    at io.grpc.okhttp.OkHttpProtocolNegotiator.negotiate(OkHttpProtocolNegotiator.java:100)    at io.grpc.okhttp.OkHttpProtocolNegotiator$AndroidNegotiator.negotiate(OkHttpProtocolNegotiator.java:218)    at io.grpc.okhttp.OkHttpTlsUpgrader.upgrade(OkHttpTlsUpgrader.java:63)    at io.grpc.okhttp.OkHttpClientTransport$3.run(OkHttpClientTransport.java:552)    ... 4 moreCaused by: java.security.cert.CertificateException:java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.    at com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:549)    at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:401)    at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:375)    at com.android.org.conscrypt.TrustManagerImpl.getTrustedChainForServer(TrustManagerImpl.java:304)    at android.security.net.config.NetworkSecurityTrustManager.checkServerTrusted(NetworkSecurityTrustManager.java:94)    at android.security.net.config.RootTrustManager.checkServerTrusted(RootTrustManager.java:88)    at com.android.org.conscrypt.Platform.checkServerTrusted(Platform.java:178)    at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:596)    at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(NativeMethod)    at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:357)    ... 8 moreCaused by: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.    ... 18 more

note that i also tried this way in documentation: https://developer.android.com/privacy-and-security/security-config


Viewing all articles
Browse latest Browse all 649

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>