codecamp

验证服务端HTTPS

由于并不是CA颁发,很有可能是公司自己生成的SSL,比如12306,框架默认是请求不通过的,但是又不希望不验证SSL, 这个时候你应该向SSL颁发的同学给到SSL客户端证书。然后按照如下方式使用。

 //自签SSL,可以指定客户端证书
    String mzlionIndexContent = HttpClient
        .get("https://kyfw.12306.cn/otn/")
        .https(this.getClass().getClassLoader().getResourceAsStream("SRCA.cer"))
        .execute()
        .asString();

忽略HTTPS
SSL双向认证
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

easy-okhttp 总结

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }