In your connection string, add ?ssl_mode=REQUIRED instead of ?ssl=true. This is the syntax for libmysqlclient (MySQL docs confusingly refer to ssl-mode and sslMode which are not available with libmysqlclient).
?ssl_mode=REQUIRED
?ssl=true
libmysqlclient
ssl-mode
sslMode