问题:由于项目中有直播模块,导致IOS审核一直被卡,都卡了一个多月,所以导致了一个问题,如果HTTPS证书过期了,Ios又升级不了,APP就直接奔溃
解决:检测证书过期,自动降级处理
Android描述:项目由OkHttp3+Retrofit构造,下面代码展示如何检测到证书过期,如何重试该接口,以及如果修改证书
1、使用拦截器检测证书过期,主要是抓SSLHandshakeException
重试接口代码是返回的那句话:return chain.proceed(newRequest);
注意response的使用,如果toString之后,因为response是流形式存在,会被close掉,从而报错
/** * ssl证书过期拦截器 */ public class SslExpiredInterceptor implements Interceptor { private Context mContext; public SslExpiredInterceptor(Context mContext) { this.mContext = mContext; } @Override public Response intercept(Chain chain) throws IOException { Response response; try { response = chain.proceed(chain.request()); } catch (SSLHandshakeException e) { //将原来的Okhttp换掉 HttpRe