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

Add docs and tests for Requests support #67

Merged
merged 8 commits into from
Jul 31, 2022
Merged

Add docs and tests for Requests support #67

merged 8 commits into from
Jul 31, 2022

Conversation

sethmlarson
Copy link
Owner

Closes #66

Copy link
Collaborator

@davisagli davisagli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

docs/source/index.md Outdated Show resolved Hide resolved
docs/source/index.md Outdated Show resolved Hide resolved
@sethmlarson
Copy link
Owner Author

Interesting the Python 3.10 and macOS for Requests seems to be consistently failing on revoked.badssl.com but urllib3 works fine. I wonder why that is? 😕

@davisagli
Copy link
Collaborator

I'm busy this morning but will take a look later. Maybe the flags related to revocation checks are not getting set correctly when the certifi CA certs have been loaded.

@davisagli
Copy link
Collaborator

@sethmlarson I added code to explicitly configure macOS security policy to require revocation checks when verify_flags includes VERIFY_CRL_CHECK_CHAIN. I'm still not really sure why the behavior was different when testing with requests; it seems the presence of the certifi CAs somehow caused macOS to either not do revocation checks it was otherwise doing, or to ignore failures when trying to do them.

davisagli
davisagli previously approved these changes Jul 30, 2022
Copy link
Collaborator

@davisagli davisagli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sethmlarson approving so it's mergeable since you opened the PR, but I'd appreciate if you could take a look at the part I added first.

ctypes.byref(CoreFoundation.kCFTypeArrayCallBacks),
)
CoreFoundation.CFArrayAppendValue(policies, ssl_policy)
revocation_policy = Security.SecPolicyCreateRevocation(
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davisagli Do we need to CFRelease the ssl_policy and revocation_policy objects below as well?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sethmlarson Yes, having reviewed docs about CoreFoundation memory management more closely, I think you're right.

@@ -38,6 +40,8 @@ class FailureHost:
"Hostname mismatch, certificate is not valid for 'wrong.host.badssl.com'",
# macOS
"certificate name does not match",
# macOS with revocation checks
"certificates do not meet pinning requirements",
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davisagli This is a strange message for the situation, makes me think of certificate pinning or macOS minimum requirements for certs. What's the full error message here if you have that handy?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SSLCertVerificationError('"*.badssl.com","R3","ISRG Root X1" certificates do not meet pinning requirements')

Here is someone else configuring a revocation security policy similar to us, who noted that it's returning errSecIncompleteCertRevocationCheck = -67635 indicating that a revocation check could not be completed (which makes more sense), but that CFErrorCopyDescription is returning the wrong error message for that error code: https://developer.apple.com/forums/thread/706629

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find!! That looks like exactly what we're experiencing.

@sethmlarson sethmlarson merged commit c7aafd0 into main Jul 31, 2022
@sethmlarson sethmlarson deleted the requests-docs branch July 31, 2022 01:11
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

Successfully merging this pull request may close these issues.

Document how to use truststore with requests
2 participants