This is very insecure as it defeats one of the points of SSL: Making sure your connecting to the right server.
You should seriously consider to import the certificate into your truststore instead! See e.g. Telling Java to accept self-signed certificates.