Problem fixed!
The code and configuration were all correct, one necessary piece of info to know is that Mendix changes the certificate file's password while importing them, so
Core.getConfiguration().getClientCertificatePasswords().get(0)
returns a password that is not the same as the password you used to create the certificate, knowing this lead to solving the problem.