gpt4 book ai didi

android - 使用 rest client 和 androidannotations 忽略 SSL

转载 作者:太空宇宙 更新时间:2023-11-03 14:59:07 25 4
gpt4 key购买 nike

我正在尝试使用带有客户端和 androidannotations 的 rest api。它工作得很好,但是当我使用无效证书执行 api 时返回了一个错误。

org.springframework.web.client.ResourceAccessException: I/O error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.; nested exception is javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

我找到了几个解决方案(如 Trusting all certificates using HttpClient over HTTPS)来忽略此验证(仅在开发中,生产中具有正确的证书),但没有一个能够将它与 rest 和 androidannotations 客户端结合起来。

有人知道怎么做吗?

最佳答案

让带注释的服务接口(interface)像这样实现 RestClientSupport:

@Rest
public interface MyService extends RestClientSupport

然后就可以调用了

RestTemplate t = service.getRestTemplate();

并按照以下说明操作:

http://www.jroller.com/jurberg/entry/using_a_hostnameverifier_with_spring

关于android - 使用 rest client 和 androidannotations 忽略 SSL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25134416/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com