Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 5 ! A lot of things are not working #63

Open
Ricoeva01 opened this issue Feb 8, 2021 · 3 comments
Open

Chapter 5 ! A lot of things are not working #63

Ricoeva01 opened this issue Feb 8, 2021 · 3 comments

Comments

@Ricoeva01
Copy link

I am following the chapter 5 and get stuck on the bookmarklet image. Even if I launch the Python manage.py run server_plus --cert-file cert.crt it doesn't work on my safari web browser, and in chrome neither.

I've got when I clicked on the button bookmarks a pop up window with nothing that I can do inside.
image

here an example.
Can you please help

@Ricoeva01
Copy link
Author

ok I finale succeeded with Firefox.
it seems to work until I clicked on bookmark it button !
Capture d’écran 2021-02-08 à 18 18 49
Capture d’écran 2021-02-08 à 18 19 08

Here the answer when I clicked on the bookmark it button !!

urllib.error.URLError

urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1108)>

`

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 1319, in do_open

h.request(req.get_method(), req.selector, req.data, headers,

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1230, in request

self._send_request(method, url, body, headers, encode_chunked)

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1276, in _send_request

self.endheaders(body, encode_chunked=encode_chunked)

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1225, in endheaders

self._send_output(message_body, encode_chunked=encode_chunked)

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1004, in _send_output

self.send(msg)

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 944, in send

self.connect()

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1399, in connect

self.sock = self._context.wrap_socket(self.sock,

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 500, in wrap_socket

return self.sslsocket_class._create(

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 1040, in _create

self.do_handshake()

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 1309, in do_handshake

self._sslobj.do_handshake()

During handling of the above exception, another exception occurred:
File "/Users/ricardoponce/Documents/WebSocial/venv/lib/python3.8/site-packages/django/contrib/staticfiles/handlers.py", line 76, in __call__

return self.application(environ, start_response)

File "/Users/ricardoponce/Documents/WebSocial/venv/lib/python3.8/site-packages/django/core/handlers/wsgi.py", line 133, in __call__

response = self.get_response(request)

File "/Users/ricardoponce/Documents/WebSocial/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 128, in get_response

response = self._middleware_chain(request)

File "/Users/ricardoponce/Documents/WebSocial/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 49, in inner

response = response_for_exception(request, exc)

File "/Users/ricardoponce/Documents/WebSocial/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 103, in response_for_exception

response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())

File "/Users/ricardoponce/Documents/WebSocial/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 138, in handle_uncaught_exception

return debug.technical_500_response(request, *exc_info)

File "/Users/ricardoponce/Documents/WebSocial/venv/lib/python3.8/site-packages/django_extensions/management/technical_response.py", line 37, in null_technical_500_response

six.reraise(exc_type, exc_value, tb)

File "/Users/ricardoponce/Documents/WebSocial/venv/lib/python3.8/site-packages/six.py", line 702, in reraise

raise value.with_traceback(tb)

File "/Users/ricardoponce/Documents/WebSocial/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner

response = get_response(request)

File "/Users/ricardoponce/Documents/WebSocial/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 179, in _get_response

response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/Users/ricardoponce/Documents/WebSocial/venv/lib/python3.8/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view

return view_func(request, *args, **kwargs)

File "/Users/ricardoponce/Documents/WebSocial/bookmarks/images/views.py", line 23, in image_create

new_item = form.save(commit=False)

File "/Users/ricardoponce/Documents/WebSocial/bookmarks/images/forms.py", line 35, in save

response = request.urlopen(image_url)

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 222, in urlopen

return opener.open(url, data, timeout)

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 525, in open

response = self._open(req, data)

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 542, in _open

result = self._call_chain(self.handle_open, protocol, protocol +

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 502, in _call_chain

result = func(*args)

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 1362, in https_open

return self.do_open(http.client.HTTPSConnection, req,

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 1322, in do_open

raise URLError(err)

urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1108)>

`

@taylort91
Copy link

I ended up skipping over this chapter. After some mild research, there are quite a bit of websites (Google and Amazon for example) that disabled us from pulling images from them. I did find some random websites were this did work though.

@timotif
Copy link

timotif commented Aug 9, 2021

I found the answer to this in another thread.
#6 (comment)

change the forms.py as follows.
Add the the certifi import
import certifi
change the urlopen call to as below.

response = request.urlopen(image_url,cafile=certifi.where())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants