In my connection string i setthe trustcertificate to true, in my windows pc i am able to connect. However when connecting to my android i get this error →
Npgsql.NpgsqlException: 'Exception while performing SSL
Make sure that the SSL certificate of your PostgreSQL server is trusted by the Android system. You can manually install the certificate on the Android device.
Export the certificate
Transfer to Android (email / cloud storage / direct USB)
Install the certificate. It might depend on your version/flavour of Android, but if you search for “certificate” in Settings, you should find it (I found it on mine).
After installation, it should appear in “User certificates” or “Trusted Credentials” (in the User tab).
And did you find any more information with adb logcat -s "SSL" ?
You can also try checking Npgsql logs. You can enable logging to get details on what Npgsql is doing behind the scenes during the connection phase, which can help you diagnose SSL issues. For example:
using Microsoft.Extensions.Logging;
// Create a new LoggerFactory
var loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddConsole().SetMinimumLevel(LogLevel.Debug);
});
// Attach the logger factory to Npgsql
NpgsqlLogManager.Provider = new ExtensionsLoggingProvider(loggerFactory);
// Your Npgsql connection code here
This will output Npgsql logs to the console, including the steps taken during the SSL handshake. You’ll get more details about what Npgsql is doing, which could hint at why the SSL operation is failing.
You can also have a look at the “Logs” menu in the left panel of the Aiven Console. Maybe you’ll gain more information as to why the connection was refused.
As a rule of thumb, you should try identifying if the issue is specific to Npgsql or a more general SSL issue.
A last idea would be to check that there is no Android Network Policy (VPN, firewall rules, a custom network security config…) blocking the connection.