gpt4 book ai didi

android - https 与具有自签名证书的服务器

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

我正在使用不受信任的证书关注 https 的 android 教程。参见 here .

他们提供了 CA 不受信任时场景的示例代码。我的服务器上有自签名证书的场景。所以我无法弄清楚我在他们的示例代码中用以下内容替换了以下内容:

InputStream caInput = new BufferedInputStream(new FileInputStream("load-der.crt"));

// I can't figure out where to get my crt from ?
// I don't have access to that path directly from a URL

对于自签名证书,他们说:

You can create your own TrustManager, this time trusting 
the server certificate directly.

我是否单独获得了服务器的自签名证书? API 不会以某种方式自动为我获取它吗?

最佳答案

Do I have separately get my server's self-signed certificate ?

我不知道“单独”在这种情况下是什么意思,但您需要包含自签名证书的 keystore 以进行验证。

Will the API not get that for me automatically in some way ?

怎么可能呢?验证证书背后的要点是确认它确实是正确的,并且您的用户不是中间人攻击的受害者。要为自签名证书执行此操作,我们需要相关详细信息来进行验证。

FWIW,如果你觉得这个东西设置起来有点复杂,我有 a TrustManagerBuildermy CWAC-Security library这会有所帮助。

关于android - https 与具有自签名证书的服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24286338/

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