相关疑难解决方法(0)

抛出SSLError的Python请求

我正在编写一个涉及CAS,jspring安全检查,重定向等的简单脚本.我想使用Kenneth Reitz的python请求,因为它是一项很棒的工作!但是,CAS需要通过SSL进行验证,因此我必须先通过该步骤.我不知道Python的要求是什么?这个SSL证书应该驻留在哪里?

Traceback (most recent call last):
  File "./test.py", line 24, in <module>
  response = requests.get(url1, headers=headers)
  File "build/bdist.linux-x86_64/egg/requests/api.py", line 52, in get
  File "build/bdist.linux-x86_64/egg/requests/api.py", line 40, in request
  File "build/bdist.linux-x86_64/egg/requests/sessions.py", line 209, in request 
  File "build/bdist.linux-x86_64/egg/requests/models.py", line 624, in send
  File "build/bdist.linux-x86_64/egg/requests/models.py", line 300, in _build_response
  File "build/bdist.linux-x86_64/egg/requests/models.py", line 611, in send
requests.exceptions.SSLError: [Errno 1] _ssl.c:503: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Run Code Online (Sandbox Code Playgroud)

python ssl urllib3 python-requests

309
推荐指数
15
解决办法
54万
查看次数

javax.net.ssl.SSLHandshakeException:在Web服务通信期间握手期间远程主机关闭连接

我收到javax.net.ssl.SSLHandshakeException:当我尝试通过互联网进行Web服务的HTTPS发布时,握手异常期间远程主机关闭连接.但是相同的代码适用于其他Internet托管的Web服务.我尝试过很多东西,没有什么可以帮助我.我在这里发布了示例代码.有谁可以帮我解决这个问题?

public static void main(String[] args) throws Exception {

    String xmlServerURL = "https://example.com/soap/WsRouter";
    URL urlXMLServer = new URL(xmlServerURL);
    // URLConnection supports HTTPS protocol only with JDK 1.4+ 
    Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(
            "xxxx.example.com", 8083));
    HttpURLConnection httpsURLConnection = (HttpURLConnection) urlXMLServer
            .openConnection(proxy);
    httpsURLConnection.setRequestProperty("Content-Type","text/xml; charset=utf-8");
    //httpsURLConnection.setDoInput(true);
    httpsURLConnection.setDoOutput(true);
    httpsURLConnection.setConnectTimeout(300000);
    //httpsURLConnection.setIgnoreProxy(false);
    httpsURLConnection.setRequestMethod("POST"); 
    //httpsURLConnection.setHostnameVerifier(DO_NOT_VERIFY); 
    // send request
    PrintWriter out = new PrintWriter(
            httpsURLConnection.getOutputStream());
    StringBuffer requestXML = new StringBuffer();
    requestXML.append(getProcessWorkOrderSOAPXML());   
    // get list of user     
    out.println(requestXML.toString()); 
    out.close();
    out.flush();
    System.out.println("XML …
Run Code Online (Sandbox Code Playgroud)

java ssl webservice-client

66
推荐指数
6
解决办法
32万
查看次数

ssl.SSLError:tlsv1警报协议版本

我正在将REST API用于Cisco CMX设备,并尝试编写Python代码,该代码向API发出GET请求以获取信息.代码如下,除了更改必要的信息外,与文件中的代码相同.

from http.client import HTTPSConnection
from base64 import b64encode


# Create HTTPS connection
c = HTTPSConnection("0.0.0.0")

# encode as Base64
# decode to ascii (python3 stores as byte string, need to pass as ascii 
value for auth)
username_password = b64encode(b"admin:password").decode("ascii")
headers = {'Authorization': 'Basic {0}'.format(username_password)}

# connect and ask for resource
c.request('GET', '/api/config/v1/aaa/users', headers=headers)

# response
res = c.getresponse()

data = res.read()
Run Code Online (Sandbox Code Playgroud)

但是,我不断收到以下错误:

Traceback (most recent call last):
  File "/Users/finaris/PycharmProjects/test/test/test.py", line 14, in <module>
    c.request('GET', '/api/config/v1/aaa/users', …
Run Code Online (Sandbox Code Playgroud)

python ssl https cisco

29
推荐指数
6
解决办法
8万
查看次数

Python SSL连接"EOF违反协议"

我正在使用Django Celery任务连接到使用Gevent请求lib的Facebook Graph API.我一直在运行的问题是,我偶尔会发生违反协议异常的EOF.我已经四处搜索,各种来源提供了不同的修复,但似乎都没有.

我试过猴子修补ssl模块(gevent.monkey.patch_all())和其他一些但没有运气.

我甚至不确定这是否是openssl问题,因为一些消息来源可能会建议我在应用Gevent优化之前没有遇到过它

Connection error: [Errno 8] _ssl.c:504: EOF occurred in violation of protocol
Traceback (most recent call last):
File "/home/user/workspace/startup/project/events/tasks.py", line 52, in _process_page
data = requests.get(current_url)
File "/home/user/workspace/startup/env/local/lib/python2.7/site-packages/requests/api.py", line 55, in get
return request('get', url, **kwargs)
File "/home/user/workspace/startup/env/local/lib/python2.7/site-packages/requests/api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "/home/user/workspace/startup/env/local/lib/python2.7/site-packages/requests/sessions.py", line 354, in request
resp = self.send(prep, **send_kwargs)
File "/home/user/workspace/startup/env/local/lib/python2.7/site-packages/requests/sessions.py", line 460, in send
r = adapter.send(request, **kwargs)
File "/home/user/workspace/startup/env/local/lib/python2.7/site-packages/requests/adapters.py", line 250, in send
raise SSLError(e)
SSLError: …
Run Code Online (Sandbox Code Playgroud)

python django celery gevent python-requests

23
推荐指数
1
解决办法
5万
查看次数

SSL坏握手错误10054"WSAECONNRESET"

笔记:

versions

Python 2.7.11 and my requests version is '2.10.0'
'OpenSSL 1.0.2d 9 Jul 2015'
Please read the below comment by Martijn Pieters before reproducing 
Run Code Online (Sandbox Code Playgroud)

最初我尝试https://www.neco.navy.mil/necoattach/N6945016R0626_2016-06-20__INFO_NAS_Pensacola_Base_Access.docx使用以下代码获取pdf

代码1:

>>> import requests
>>> requests.get("https://www.neco.navy.mil/necoattach/N6945016R0626_2016-06-20__INFO_NAS_Pensacola_Base_Access.docx",verify=False)
Run Code Online (Sandbox Code Playgroud)

错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\mob140003207\AppData\Local\Enthought\Canopy\User\lib\site-packa
ges\requests\api.py", line 67, in get
    return request('get', url, params=params, **kwargs)
  File "C:\Users\mob140003207\AppData\Local\Enthought\Canopy\User\lib\site-packa
ges\requests\api.py", line 53, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Users\mob140003207\AppData\Local\Enthought\Canopy\User\lib\site-packa
ges\requests\sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs) …
Run Code Online (Sandbox Code Playgroud)

python ssl python-2.7 python-requests

11
推荐指数
1
解决办法
1万
查看次数

强制请求库在Python中使用TLSv1.1或TLSv1.2

我正在尝试使用python中的请求库向服务器发送POST调用.之前我能够成功发送POST调用,但最近,服务器弃用了TLSv1.0,现在只支持TLSv1.1和TLSv1.2.现在相同的代码抛出一个"requests.exceptions.SSLError:EOF发生违反协议(_ssl.c:590)"错误.

我在stackoverflow上发现了这个线程Python请求requests.exceptions.SSLError:[Errno 8] _ssl.c:504:EOF违反了协议,这表示我们需要继承HTTPAdapter,之后会话对象将使用TLSv1.我相应地更改了我的代码,这是我的新代码

class MyAdapter(HTTPAdapter):
    def init_poolmanager(self, connections, maxsize, block=False):
    self.poolmanager = PoolManager(num_pools=connections,
                               maxsize=maxsize,
                               block=block,
                               ssl_version=ssl.PROTOCOL_TLSv1)

url="https://mywebsite.com/ui/"
headers={"Cookie":"some_value","X-CSRF-Token":"some value","Content-Type":"application/json"}    
payload={"name":"some value","Id":"some value"}    
s = requests.Session()
s.mount('https://', MyAdapter())

r=s.post(url,json=payload,headers=headers)
html=r.text
print html
Run Code Online (Sandbox Code Playgroud)

但即使使用了这个,我也得到了同样的错误"违反协议的EOF(_ssl.c:590)".

我的第一个问题是,我在某处读取默认使用ssl的请求.我知道我的服务器使用的是TLSv1.0,我的代码是否正常工作,因为TLSv1.0与ssl3.0向后兼容?

我的第二个问题是,我上面提到的stackoverflow线程使用了我将我的代码更改为子类HTTPAdapter,表示这将适用于TLSv1.但是由于我的服务器中不推荐使用TLSv1.0,这段代码仍然有效吗?

python ssl

8
推荐指数
1
解决办法
2万
查看次数

urllib3 on python 2.7 Google App Engine上的SNI错误

我正在尝试使用SNI从我在Google App Engine上托管的网站下载HTTPS页面.无论我使用什么库,我都会收到以下错误:

[Errno 8] _ssl.c:504: EOF occurred in violation of protocol
Run Code Online (Sandbox Code Playgroud)

我尝试过多种方式解决错误,包括使用urllib3 openssl monkeypatch:

from urllib3.contrib import pyopenssl
pyopenssl.inject_into_urllib3
Run Code Online (Sandbox Code Playgroud)

但我总是得到上面提到的同样的错误.

有任何想法吗?

python google-app-engine urllib3 sni

5
推荐指数
1
解决办法
5329
查看次数

httplib2中的SSL版本 - EOF违反协议

我正在向httplib2拥有的REST服务发出HTTPS GET请求,但是我们收到错误:

[Errno 8] _ssl.c:504: EOF occurred in violation of protocol
Run Code Online (Sandbox Code Playgroud)

所有其他客户端运行良好(浏览器,Java客户端等...),但需要将PHP curl设置为使用SSL v3.

我已经四处搜索,似乎确实是关于SSL版本的错误,但我似乎找不到在httplib2中更改它的方法.除了更改源代码中的以下行之外,还有什么办法吗?

# We should be specifying SSL version 3 or TLS v1, but the ssl module
# doesn't expose the necessary knobs. So we need to go with the default
# of SSLv23.
return ssl.wrap_socket(sock, keyfile=key_file, certfile=cert_file,
                       cert_reqs=cert_reqs, ca_certs=ca_certs)
Run Code Online (Sandbox Code Playgroud)

python ssl httplib2

4
推荐指数
1
解决办法
4668
查看次数

Python 3.4 SSL错误urlopen错误EOF发生违反协议(_ssl.c:600)

我使用Arch Linux,python 3.4,openSSL 1.0.2d.当我向https://www.supercash.cz/提出请求时,我收到此错误.如果我使用请求或构建urllib并不重要,则始终存在相同的错误.此网站的SSL证书在Chrome浏览器中可以正常使用.

File "/usr/lib64/python3.4/urllib/request.py", line 463, in open
    response = self._open(req, data)
File "/usr/lib64/python3.4/urllib/request.py", line 481, in _open
    '_open', req)
File "/usr/lib64/python3.4/urllib/request.py", line 441, in _call_chain
    result = func(*args)
File "/usr/lib64/python3.4/urllib/request.py", line 1225, in https_open
    context=self._context, check_hostname=self._check_hostname)
File "/usr/lib64/python3.4/urllib/request.py", line 1184, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error EOF occurred in violation of protocol (_ssl.c:600)>
Run Code Online (Sandbox Code Playgroud)

我试过这个,但它只适用于python2.7 错误 - urlopen错误[Errno 8] _ssl.c:504:EOF发生违反协议,需要帮助

这是ssl测试的结果https://www.ssllabs.com/ssltest/analyze.html?d=supercash.cz

python ssl python-3.x python-3.4

4
推荐指数
2
解决办法
2万
查看次数