Android implements HTTPS two-way verification

HttpClient implements HTTPS two-way verification

Due to the security of HTTPS, I believe most companies choose this protocol. However, there are many pits that cannot be avoided during the development process. Today, I will solve the problems I encountered today.

verification method

There are one-way authentication and two-way authentication

One-way authentication

Mutual authentication

双向认证实质上就是服务端和客户端都进行证书校验。
证书的生成让服务器的同学生成给你就可以,如果想自己生成,自己问度娘

OKHTTP and HttpURLConnection in the project are relatively easy to write, you can go to the project to have a look, please read the source code address.

The focus of HTTPClient is here:

HTTPClient

javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

Attach source code download link

Guess you like

Origin blog.csdn.net/honeylife/article/details/105228341