@Bean public HttpsUrlConnectionMessageSender httpsUrlConnectionMessageSender() throws Exception { HttpsUrlConnectionMessageSender httpsUrlConnectionMessageSender = new HttpsUrlConnectionMessageSender(); httpsUrlConnectionMessageSender.setTrustManagers(trustManagersFactoryBean().getObject()); // allows the client to skip host name verification as otherwise following error is thrown: // java.security.cert.CertificateException: No name matching localhost found httpsUrlConnectionMessageSender.setHostnameVerifier(new HostnameVerifier() { @Override public boolean verify(String hostname, javax.net.ssl.SSLSession sslSession) { if ("localhost".equals(hostname)) { return true; } return false; } }); return httpsUrlConnectionMessageSender; }