如何在apk上添加SSL证书? [英] How can I add a SSL certificate on my apk?

查看:3481
本文介绍了如何在apk上添加SSL证书?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试连接 https url。

I am trying to make a connection to an https url.

我面临的问题是当我尝试通过 WebView连接时,我收到以下错误:

The problem that I am facing is that when I am trying to connect via WebView I am getting the following error:


无法验证证书链,错误:java.security.cert.CertPathValidatorException:找不到证书路径的信任锚。

Failed to validate the certificate chain, error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

I已经搜索了很多,但大多数关于此错误的回复是忽略错误并让网址没有问题。

I have searched a lot but most of the responses about this error is to ignore the error and let the url goes without problems.

似乎如果我在我的网站上添加证书Android手机运行良好,但它确实有任何意义,我必须在我想要安装de app的每个设备中添加SSL证书(因为他们将是第三方客户端)。

It seems that if I add the certificate on my Android phone it works well but it does have any sense that I would have to add the certificate of SSL in each device I want to install de app (because they will be third party clients).

因此,我考虑过将证书添加到apk中,这样应用程序的用户就不会有证书错误,他们就可以连接到那个 https url。

Because of this, I have thought about add the certificate into the apk so the users of the application will not have errors with that certificate and they will be able to connect to that https url.

是否可以在apk上添加SSL证书?

Is it possible to add SSL certificate on the apk?

提前致谢!

推荐答案

设置和安装非常简单如果使用本地服务器,请学习SSL。

It will be very easy to setup & learn SSL if you go with a local server.

1]为SSL通信设置服务器(例如; TomCat)( https://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html ) 。

1 ] Setup a Server (For Eg; TomCat) for SSL communications (https://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html).

2]编写一个简单的Web服务( http://www.radcortez.com/ssl-tls-rest-server-client-with-spring-and-tomee/ )。

2 ] Write a simple Web-Service (http://www.radcortez.com/ssl-tls-rest-server-client-with-spring-and-tomee/).

3]使用任何一种工具(Keytool,OpenSSL等)准备自签名证书

3 ] Prepare a self -signed certificate using any one of the tool (Keytool , OpenSSL etc)

4]建议使用命令来创建密钥库,证书等。但对于懒人来说,有一个基于GUI的程序:)( http://keystore-explorer.org/downloads.html

4 ] It is adviced to use commands to create keystore,certificate etc.But for the lazy people there is a GUI based program :) (http://keystore-explorer.org/downloads.html)

5]现在,是时候将SSL证书固定到Android Applications.Add您的别名。 cer(它可以从[4]中提到的s / w导出)

5 ] Now ,It's time to pin SSL certificate to Android Applications.Add your aliasname.cer (It can export from s/w mentioned in point [4])

6]以编程方式检查主机名( https://infinum.co/the-capsized-eight/securing-mobile- bank-on-android-with-ssl-certificate-pinning )。

6 ] Check host name programatically (https://infinum.co/the-capsized-eight/securing-mobile-banking-on-android-with-ssl-certificate-pinning).

7]创建一个自定义信任管理器,这样我们就可以省略android系统的默认信任管理器( https://github.com/ikust/hello-pinnedcerts

7 ] Create a custom Trust Manager,So that we , can omit android system's default Trust Manager (https://github.com/ikust/hello-pinnedcerts)

这篇关于如何在apk上添加SSL证书?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆