I’m running into an error connecting a Couchbase Lite Android client to sync gateway over wss://
TLS, getting the error “server TLS certificate untrusted”. These are the logcat logs:
2021-01-14 12:27:45.607 8147-9153/? E/CouchbaseLite/NETWORK: {N8litecore4repl12C4SocketImplE#5} WebSocket failed to connect! (reason=Network error 8)
2021-01-14 12:27:45.611 8147-8250/? E/CouchbaseLite/REPLICATOR: {Repl#6} Got LiteCore error: Network error 8 "server TLS certificate untrusted"
2021-01-14 12:27:45.671 8147-8147/? W/Couchbase: ReplicatorChange{replicator=Replicator{@0xe741373(<*>),Database{@0x1039856, name='911705151-synced'} => URLEndpoint{url=wss://********:4984/db}}, status=Status{activityLevel=CONNECTING, progress=Progress{completed=0, total=0}, error=CouchbaseLiteException{CouchbaseLite,5008,'server TLS certificate untrusted
(CouchbaseLite Android v2.8.1-1 (EE/release, Commit/a9c0287d1e@a10b5970562a Core/2.8.1 (1) at 2020-10-31T20:34:35.308Z) on Java; Android 11; sdk_gphone_x86_arm)'}}}
2021-01-14 12:27:45.720 8147-8147/? W/Couchbase: ReplicatorChange{replicator=Replicator{@0xe741373(<*>),Database{@0x1039856, name='911705151-synced'} => URLEndpoint{url=wss://********:4984/db}}, status=Status{activityLevel=STOPPED, progress=Progress{completed=0, total=0}, error=CouchbaseLiteException{CouchbaseLite,5008,'server TLS certificate untrusted
(CouchbaseLite Android v2.8.1-1 (EE/release, Commit/a9c0287d1e@a10b5970562a Core/2.8.1 (1) at 2020-10-31T20:34:35.308Z) on Java; Android 11; sdk_gphone_x86_arm)'}}}
If I change the endpoint to the ws://
scheme, it refuses the connection:
2021-01-14 12:22:22.576 7779-7938/? E/CouchbaseLite/NETWORK: {N8litecore4repl12C4SocketImplE#1} WebSocket failed to connect! (reason=WebSocket/HTTP status 1000)
2021-01-14 12:22:22.584 7779-7919/? E/CouchbaseLite/REPLICATOR: {Repl#2} Got LiteCore error: WebSocket error 1001 "WebSocket connection closed by peer"
2021-01-14 12:22:23.228 7779-7779/? W/Couchbase: ReplicatorChange{replicator=Replicator{@0x9b119e1(<*>),Database{@0xc2fc818, name='911705151-synced'} => URLEndpoint{url=ws://********:4984/db}}, status=Status{activityLevel=CONNECTING, progress=Progress{completed=0, total=0}, error=CouchbaseLiteException{CouchbaseLite,11001,'WebSocket connection closed by peer
(CouchbaseLite Android v2.8.1-1 (EE/release, Commit/a9c0287d1e@a10b5970562a Core/2.8.1 (1) at 2020-10-31T20:34:35.308Z) on Java; Android 11; sdk_gphone_x86_arm)'}}}
2021-01-14 12:22:23.235 7779-7779/? W/Couchbase: ReplicatorChange{replicator=Replicator{@0x9b119e1(<*>),Database{@0xc2fc818, name='911705151-synced'} => URLEndpoint{url=ws://********:4984/db}}, status=Status{activityLevel=STOPPED, progress=Progress{completed=0, total=0}, error=CouchbaseLiteException{CouchbaseLite,11001,'WebSocket connection closed by peer
(CouchbaseLite Android v2.8.1-1 (EE/release, Commit/a9c0287d1e@a10b5970562a Core/2.8.1 (1) at 2020-10-31T20:34:35.308Z) on Java; Android 11; sdk_gphone_x86_arm)'}}}
I can connect to the sync gateway over https
in the browser just fine, including in Chrome on the Android device. The root certificate is signed by Amazon.