Detailed steps of using HTTPS configuration in Android project

preface

If the network framework of your project is okhttp, it is easy to use HTTPS, because okhttp supports HTTPS by default. Portal

I won't say much about the following. Let's take a look at the detailed introduction:

Steps for configuring Android using HTTPS.

1、step

Configure hostnameverifier

2.step

Configure sslsocketfactory

Call getsslsocketfactory (null, null, null).

3.step

Set okhttpclient.

The first parameter of the method getsslsocketfactory (null, null) was supposed to be passed in the self signed certificate. When null is passed in, the self signed certificate can be ignored.

If you want to try not to ignore the self signed certificate, you can call the following method to obtain sslsocketfactory. And set it to okhttpclient.

Through the above steps, you can use HTTPS self signed certificate and one-way authenticated HTTPS.

Glide access pictures of HTTPS

1.step

Introduce the following AAR in build. Gradle

2.step

Set the okhttpclient of the verified certificate to glide.

summary

The above is the whole content of this article. I hope the content of this article can bring some help to your study or work. If you have any questions, you can leave a message. Thank you for your support for programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>