Currently, for Android Peer-to-Peer communication, we are using the following library and code:
Library:
com.couchbase.lite:couchbase-lite-android-ee:3.0.12
Working Existing Code:
listenerConfig.setAuthenticator(ListenerCertificateAuthenticator(caCertificates))
val listener = URLEndpointListener(listenerConfig)
We are passing a CA certificate to the ListenerCertificateAuthenticator to verify the incoming client certificate and establish a connection.
However, based on our new requirements, we need to perform additional checks in addition to the certificate verification. Therefore, following the guidelines in the Couchbase documentation, we are delegating authentication to a custom class that implements ListenerCertificateAuthenticatorDelegate. (Please refer to the updated code below.)
Couchbase Documentation:
Updated Code:
class Delegate : ListenerCertificateAuthenticatorDelegate {
override fun authenticate(certs: List<Certificate>): Boolean {
val valid = true // Our code eventually returns true.
return valid
}
}
listenerConfig.setAuthenticator(ListenerCertificateAuthenticator(Delegate()))
Although we return true during authentication, the connection still fails to be established, and we are seeing the following error for the peer device(iOS) which is trying to connect. (Note: similar changes does work for iOS)
“error”: “\nCaused by Object: server rejected the TLS client certificate”
It seems like there might be an issue with the Couchbase Android library. Kindly help