zoukankan      html  css  js  c++  java
  • webmagic创始人回答:ebMagic默认的HttpClient只会用TLSv1去请求,对于某些只支持TLS1.2的站点(例如 https://juejin.im/) ,就会报错:

    见官方文档解决方案:https://github.com/code4craft/webmagic/issues/701

    webmagic创始人回答:

     code4craft commented on 29 Nov 2017 •
    
    更新会在0.7.4版本发布。
    
    临时适配方式,修改HttpClientGenerator中的buildSSLConnectionSocketFactory方法,
    
    return new SSLConnectionSocketFactory(createIgnoreVerifySSL(), new String[]{"SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2"},
                        null,
                        new DefaultHostnameVerifier())
    WebMagic默认的HttpClient只会用TLSv1去请求,对于某些只支持TLS1.2的站点(例如 https://juejin.im/) ,就会报错:
    
    javax.net.ssl.SSLException: Received fatal alert: protocol_version
    	at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
    	at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)
    	at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:2023)
    	at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1125)
    	at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
    	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
    	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
    	at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:394)
    	at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:353)
    	at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:141)
    	at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
    	at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
    	at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
    	at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
    	at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
    	at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    	at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
    	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
    	at us.codecraft.webmagic.downloader.HttpClientDownloader.download(HttpClientDownloader.java:85)
    
    现在的修改方式是在HttpClientGenerator中构建SSLConnectionSocketFactory时加上支持。
    
    做产品的程序,才是好的程序员!
  • 相关阅读:
    条件注释判断IE版本
    win7及以上系统打开chm空白或显示"无法打开"的2个解决方案
    复制和删除txt文件
    casperjs 抓取爱奇艺高清视频
    chrome扩展程序之http/https 报文拦截
    bootstrap 的 datetimepicker 结束时间大于开始时间
    Jquery EasyUI的datagrid页脚footer使用及数据统计
    Web应用程序在加入反向代理服务器的时候如何获得真实IP
    c#4.0 新特性 可选参数 可曾用过?
    Pyhon
  • 原文地址:https://www.cnblogs.com/asplover/p/12491454.html
Copyright © 2011-2022 走看看