nsfw-docker icon indicating copy to clipboard operation
nsfw-docker copied to clipboard

Issue and uncaught exception when encountering an SSLError

Open samnissen opened this issue 6 years ago • 0 comments

----------------------------------------
172.17.0.1 - - [11/Sep/2018 19:39:25] "GET /https://blog.rakutenmarketing.com/wp-content/uploads/2018/08/Holiday-Shopper_Feature-Image.png HTTP/1.1" 200 -
https://blog.rakutenmarketing.com/wp-content/uploads/2018/08/Holiday-Shopper_Feature-Image.png
ERROR:root:ok
Traceback (most recent call last):
  File "server.py", line 19, in do_GET
    message = classify_nsfw.get_score(self.path[1:])
  File "/workspace/classify_nsfw.py", line 128, in get_score
    with c.request('GET', url, preload_content=False) as resp, open(tmp_filename, 'wb') as out_file:
  File "/usr/lib/python2.7/dist-packages/urllib3/request.py", line 75, in request
    **urlopen_kw)
  File "/usr/lib/python2.7/dist-packages/urllib3/request.py", line 88, in request_encode_url
    return self.urlopen(method, url, **urlopen_kw)
  File "/usr/lib/python2.7/dist-packages/urllib3/poolmanager.py", line 155, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py", line 599, in urlopen
    raise SSLError(e)
SSLError: hostname 'blog.rakutenmarketing.com' doesn't match 'blog.marketing.rakuten.co.uk'
----------------------------------------
Exception happened during processing of request from ('172.17.0.1', 38900)
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 649, in __init__
    self.handle()
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
    self.handle_one_request()
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request
    method()
  File "server.py", line 22, in do_GET
    message = "exception: " + e.message
TypeError: cannot concatenate 'str' and 'CertificateError' objects

If I pass in any image from blog.rakutenmarketing.com, I get this error. My preferred outcome would be to ignore the SSL error altogether, like browsers seem to. However, regardless of that, there's the concatenation error on line 22.

samnissen avatar Sep 12 '18 10:09 samnissen