如何从其他Rest服务调用HTTPS Rest服务?

时间:2015-09-11 11:59:50

标签: java rest ssl ssl-certificate

我使用自签名证书(通过keytool生成)启用了Spring Cloud ConfigServer SSL。配置服务器已启动并在端口号8888上运行,使用HTTPs&只能通过HTTPS访问,我已经通过浏览器进行了测试。

现在,我的一个Spring Boot App(名为myapp)正在尝试与此ConfigServer通信以获取它的配置。当我的Spring Boot App启动时,它在尝试获取配置时出现以下错误来自ConfigServer

ConfigServicePropertySourceLocator: Could not locate PropertySource: I/O error on GET request for "https://localhost:8888/myapp/default":java.security.cert.CertificateException: No name matching localhost found; nested exception is javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No name matching localhost found

我应该在Spring Boot应用程序中安装任何东西吗?什么类似客户端SSL证书?

1 个答案:

答案 0 :(得分:2)

此链接: No matching localhost found 解释了整个故事。如果您打算在本地使用它(用于测试或开发的早期阶段),那么我建议使用第二个选项:

实施HostnameVerifier的verify()方法 它很干净,因为它在您的代码中,可以很容易地与您的同事共享,因此无需在您的代码中附加安装手册。