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

SSL issue with google oauth2 #566

Closed
stushurik opened this issue Mar 26, 2015 · 17 comments
Closed

SSL issue with google oauth2 #566

stushurik opened this issue Mar 26, 2015 · 17 comments

Comments

@stushurik
Copy link

I am using python social auth with django 1.7 and google oauth2.

After redirect from google page I have got:

Environment:

Request Method: GET
Request URL: http://vbox.net:8000/complete/google-oauth2/?state=QiVp18K58so5FVVBLb8WQnhaALal5fzy&code=4/qR3l5BH4rYNyNt-GtYx6mXl3yPo2XuLaTkHjdkFRjJg.Eh6ySpu7l_IRYFZr95uygvWJ8l2rmAI&authuser=0&num_sessions=1&prompt=consent&session_state=059c1e5d0ac0aa05eebe37df60091e8a6592a99e..d6e5

Django Version: 1.7.5
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'bootstrap3',
'tinymce',
'urlbreadcrumbs',
'social.apps.django_app.default',
'core',
'details',
'keywords',
'logins')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')

Traceback:
File "/home/olexandr/.virtualenvs/cup/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response

  1.                 response = wrapped_callback(request, _callback_args, *_callback_kwargs)
    
    File "/home/olexandr/.virtualenvs/cup/local/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  2.     response = view_func(request, _args, *_kwargs)
    
    File "/home/olexandr/.virtualenvs/cup/local/lib/python2.7/site-packages/django/views/decorators/csrf.py" in wrapped_view
  3.     return view_func(_args, *_kwargs)
    
    File "/home/olexandr/.virtualenvs/cup/local/lib/python2.7/site-packages/social/apps/django_app/utils.py" in wrapper
  4.         return func(request, backend, _args, *_kwargs)
    
    File "/home/olexandr/.virtualenvs/cup/local/lib/python2.7/site-packages/social/apps/django_app/views.py" in complete
  5.                    redirect_name=REDIRECT_FIELD_NAME, _args, *_kwargs)
    
    File "/home/olexandr/.virtualenvs/cup/local/lib/python2.7/site-packages/social/actions.py" in do_complete
  6.     user = backend.complete(user=user, _args, *_kwargs)
    
    File "/home/olexandr/.virtualenvs/cup/local/lib/python2.7/site-packages/social/backends/base.py" in complete
  7.     return self.auth_complete(_args, *_kwargs)
    
    File "/home/olexandr/.virtualenvs/cup/local/lib/python2.7/site-packages/social/backends/oauth.py" in auth_complete
  8.             method=self.ACCESS_TOKEN_METHOD
    
    File "/home/olexandr/.virtualenvs/cup/local/lib/python2.7/site-packages/social/backends/oauth.py" in request_access_token
  9.     return self.get_json(_args, *_kwargs)
    
    File "/home/olexandr/.virtualenvs/cup/local/lib/python2.7/site-packages/social/backends/base.py" in get_json
  10.     return self.request(url, _args, *_kwargs).json()
    
    File "/home/olexandr/.virtualenvs/cup/local/lib/python2.7/site-packages/social/backends/base.py" in request
  11.         raise AuthFailed(self, str(err))
    

Exception Type: AuthFailed at /complete/google-oauth2/
Exception Value: Authentication failed: [Errno 1] _ssl.c:510: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

@stushurik
Copy link
Author

I changed python 2.7.6 to 2.7.9 and still get error

AuthFailed at /complete/google-oauth2/
Authentication failed: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)

The error is raised when calling requests. with url https://accounts.google.com/o/oauth2/token.

I don`t understand why google cert is not a valid

@omab
Copy link
Owner

omab commented Apr 4, 2015

This is probably by the lack of the certificates in your server, try installing the ca-certificates package on it (if it's a debian derivative just run sudo apt-get install ca-certificates), also ensure that your server date is properly defined (use ntpdate or similar).

@omab omab closed this as completed Apr 4, 2015
@a1Gupta
Copy link

a1Gupta commented Jan 3, 2016

@stushurik How did you resolve the issue ? I am getting the same error with Django 1.8 and Python 2.7.6

@stushurik
Copy link
Author

@a1Gupta I think you should try @omab `s solution.

@a1Gupta
Copy link

a1Gupta commented Jan 4, 2016

I tried that but that's not working!

@nicolaspanel
Copy link

@a1Gupta : I have the same problem. Have you found a solution/workaround?

@varche1
Copy link

varche1 commented Feb 11, 2016

+1!

@a1Gupta
Copy link

a1Gupta commented Feb 11, 2016

I changed the requests version from 2.8 to 2.7.0 and it worked for me!

@zhang-z
Copy link

zhang-z commented Feb 12, 2016

pip uninstall -y certifi && pip install certifi==2015.04.28 solved the problem for me.
Reference: http://stackoverflow.com/questions/34646942/ssl3-get-server-certificate-certificate-verify-failed-on-python-when-requesting

@hack2learn
Copy link

@zhang-z this fixed it for me too.

1 similar comment
@sureshvv
Copy link

@zhang-z this fixed it for me too.

@aviars
Copy link

aviars commented Dec 7, 2016

I have tried this on Python2 and Python3 Ubuntu 14 and Ubuntu 16. I m still getting this error or a Bad Handshake " error depending on what version of python-social-auth im using. I have tried a number of fixes and still coming up the same error

@jpatel3
Copy link

jpatel3 commented May 15, 2017

+1 Whats the solution for this issue? I was running requests 2.3.0, upgrading to 2.14.2 throws the above error. What's the supported version of requests for python-social-auth?

@chidg
Copy link

chidg commented Jun 5, 2017

Manually specifying certifi==2015.04.28 in my requirements did the trick for me. Unfortunate to have to downgrade to a more than 2 year old version, but I guess that's the easiest workaround at this point. @jpatel3 see if that works for you. It's an issue with certifi, not requests.

@jpatel3
Copy link

jpatel3 commented Jun 5, 2017

@chidg It worked for me. I had to do pip uninstall -y certifi && pip install certifi==2015.04.28 as suggested on one of the above comments. Thanks.

@spiderbot
Copy link

@zhang-z soultion worked for me

@luisvalerio
Copy link

@zhang-z soultion worked for me too, awesome

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

No branches or pull requests