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

Object has no attribute #3

Open
VirtualPenman opened this issue Aug 14, 2019 · 3 comments
Open

Object has no attribute #3

VirtualPenman opened this issue Aug 14, 2019 · 3 comments

Comments

@VirtualPenman
Copy link

Hey there, I am fairly new to Python and trying to connect to a site through a proxy and get certificate information. (I did not know where else to post this so I really apologize if this is not the right place)
Whenever I run any of the request methods to get certs I get an object has not attribute error or an error that pertains to urllib3.

To Reproduce
Steps to reproduce the behavior:
I am following the examples in the documentation on https://cert-human.readthedocs.io/en/latest/api/api.html

Expected behavior
I am trying to follow all the examples to print the cert resultssni

Screenshots
3Capture

2Capture

1Capture

Capture

Desktop (please complete the following information):

  • OS: [Win 10]
  • Python 3.7.4 Shell

The reason I have proxies=proxies is I am behind a proxy at work and must submit a username and password to allow the proxy to access a site. This was the reason I wanted to use requests.get since they have a proxy parameter built in that I can pass. I already have defined that proxy above. I was really excited when I found your build and I assume I am just using it incorrectly.

Again I did not know what other capacity to reach you directly as I am so new, so I apologize.

@KyleKing
Copy link

tldr: Use requests 2.22.0 for now

I have the same problem

import cert_human
import requests

with cert_human.urllib3_patch():
    response = requests.get('https://www.google.com')
    store = cert_human.CertStore.from_response(response=response)

Throws a missing attribute on raw.peer

Traceback (most recent call last):
  File "get_certs.py", line 21, in <module>
    store = cert_human.CertStore.from_response(response=response)
  File "C:\..\.venv\lib\site-packages\cert_human\__init__.py", line 454, in from_response
    raise CertHumanError(error)
cert_human.CertHumanError: Response missing attribute 'raw.peer_cert', not issued using enable_urllib3_patch      

This error is only shown when using requests 2.25, but not requests 2.22 (I have not tested other versions)

@kolinger
Copy link

kolinger commented Aug 8, 2021

This did break since requests==2.24.0 (thus last working version is requests==2.23.0) since pyOpenSSL dependency was removed, see changelog: https://github.com/psf/requests/blob/master/HISTORY.md#2240-2020-06-17

Currently cert_human requires pyOpenSSL in order to work and so if requests don't use pyOpenSSL then cart_human can't work.

But there is workaround how to enable old behaviour where requests use pyOpenSSL for SSL/TLS instead of built in ssl library, see psf/requests#5443 (comment)

In result this can be fixed with following line (call before calling requests):
urllib3.contrib.pyopenssl.inject_into_urllib3()

With this workaround cert_human works even with current requests version (2.26.0).

@henribru
Copy link

henribru commented Jan 6, 2023

pyOpenSSL support has been deprecated now and will be removed in urllib3 v2.1.0
urllib3/urllib3#2680
https://urllib3.readthedocs.io/en/2.0.0a2/reference/contrib/pyopenssl.html

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

4 participants