I finally figured it out. It was a problem with the location of the trusted keystore. It's better to always add the certificates into the /var/lib/jenkins/.keystore rather than adding in the PATH_TO_JAVA_HOME/jre/lib/security/cacerts. If you still want to add the certificate into the cacerts then an ARG should be added in the application's config file:
JAVA_ARGS="-Djavax.net.ssl.trustStore=/usr/lib/jvm/java-7-oracle/jre/lib/security/cacerts"
Sometimes you may need to add the certificate in ~/.keystore