GithubHelp home page GithubHelp logo

sheagcraig / macsesh Goto Github PK

View Code? Open in Web Editor NEW
27.0 27.0 2.0 80 KB

Tools for letting the macOS Keychain verify certs for python requests

License: Other

Python 100.00%
https macos python-requests requests tacos

macsesh's Introduction

  • ๐Ÿ‘‹ Hi, Iโ€™m @sheagcraig
  • ๐Ÿ‘€ Iโ€™m interested in spores, molds and fungus
  • ๐ŸŒฑ Iโ€™m currently learning the King's Indian Defense
  • ๐Ÿ’ž๏ธ Iโ€™m looking to collaborate on world peace.
  • ๐Ÿ“ซ How to reach me: With cunning phrases and jubilent silliness.

macsesh's People

Contributors

fferino avatar jrespeto avatar sheagcraig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jrespeto dneto82

macsesh's Issues

requests 2.32 branch breaks macsesh

import macsesh
s = macsesh.Session()
s.get('REDACTED_URL', cert='CERT_NAME')
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.11/site-packages/urllib3/connectionpool.py", line 715, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/urllib3/connectionpool.py", line 404, in _make_request
    self._validate_conn(conn)
  File "/opt/homebrew/lib/python3.11/site-packages/urllib3/connectionpool.py", line 1058, in _validate_conn
    conn.connect()
  File "/opt/homebrew/lib/python3.11/site-packages/urllib3/connection.py", line 419, in connect
    self.sock = ssl_wrap_socket(
                ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/urllib3/util/ssl_.py", line 418, in ssl_wrap_socket
    context.load_cert_chain(certfile, keyfile)
FileNotFoundError: [Errno 2] No such file or directory

Reverting to the 2.31 branch fixes it.

AttributeError: module 'urllib3.util' has no attribute 'HAS_SNI'

Python 3.10, MacOS 13.6.3 (Ventura), Intel

import sys

if sys.platform.lower() == 'darwin':
    import macsesh
    macsesh.inject_into_requests()
Traceback (most recent call last):
  File "/Users/username/Projects/ProjectName/export.py", line 16, in <module>
    import macsesh
  File "/Users/username/Projects/ProjectName/.env/lib/python3.10/site-packages/macsesh/__init__.py", line 37, in <module>
    from .session import KeychainSession, Session, SimpleKeychainSession
  File "/Users/username/Projects/ProjectName/.env/lib/python3.10/site-packages/macsesh/session.py", line 8, in <module>
    from .simple_adapter import SimpleKeychainAdapter
  File "/Users/username/Projects/ProjectName/.env/lib/python3.10/site-packages/macsesh/simple_adapter.py", line 8, in <module>
    from .util import extract_from_urllib3
  File "/Users/username/Projects/ProjectName/.env/lib/python3.10/site-packages/macsesh/util.py", line 10, in <module>
    ORIGINAL_HAS_SNI = urllib3_util.HAS_SNI
AttributeError: module 'urllib3.util' has no attribute 'HAS_SNI'

Can anyone give me any suggestion how to fix that issue?

Issue with chunk transfer on python 3.10

Just a heads up.

Look like there were some changes in python > 3.9.13.

Got this error in python 3.10.6

requests.exceptions.ChunkedEncodingError: ('Connection broken: IncompleteRead(7246 bytes read, 2994 more expected)', IncompleteRead(7246 bytes read, 2994 more expected))

Think it corresponds with:

bpo-12319: Chunked transfer encoding support added to http.client.HTTPConnection requests. The urllib.request.AbstractHTTPHandler class does not enforce a Content-Length header any more. If a HTTP request has a file or iterable body, but no Content-Length header, the library now falls back to use chunked transfer-encoding.

also needed

changed

response.text

to:

try:
    data = b''
    for d in response.iter_content(chunk_size=1024):
        data += d
except requests.exceptions.ChunkedEncodingError as ex:
    print(f"Invalid chunk encoding {str(ex)}")

print(data.decoded())

Dependencies

Looks like a nice package and it seems to work well in my quick testing.

But is it necessary for it to have >100 dependencies?

Can't it depend upon just pyobjc-framework-SecurityFoundation and not all of this (via the inclusion of top-level pyobjc):

pyobjc-7.1
pyobjc-core-7.1
pyobjc-framework-AVFoundation-7.1
pyobjc-framework-AVKit-7.1
pyobjc-framework-Accounts-7.1
pyobjc-framework-AdSupport-7.1
pyobjc-framework-AddressBook-7.1
pyobjc-framework-AppleScriptKit-7.1
pyobjc-framework-AppleScriptObjC-7.1
pyobjc-framework-ApplicationServices-7.1
pyobjc-framework-Automator-7.1
pyobjc-framework-BusinessChat-7.1
pyobjc-framework-CFNetwork-7.1
pyobjc-framework-CalendarStore-7.1
pyobjc-framework-CloudKit-7.1
pyobjc-framework-Cocoa-7.1
pyobjc-framework-Collaboration-7.1
pyobjc-framework-ColorSync-7.1
pyobjc-framework-Contacts-7.1
pyobjc-framework-ContactsUI-7.1
pyobjc-framework-CoreAudio-7.1
pyobjc-framework-CoreAudioKit-7.1
pyobjc-framework-CoreBluetooth-7.1
pyobjc-framework-CoreData-7.1
pyobjc-framework-CoreLocation-7.1
pyobjc-framework-CoreMIDI-7.1
pyobjc-framework-CoreML-7.1
pyobjc-framework-CoreMedia-7.1
pyobjc-framework-CoreMediaIO-7.1
pyobjc-framework-CoreServices-7.1
pyobjc-framework-CoreSpotlight-7.1
pyobjc-framework-CoreText-7.1
pyobjc-framework-CoreWLAN-7.1
pyobjc-framework-CryptoTokenKit-7.1
pyobjc-framework-DVDPlayback-7.1
pyobjc-framework-DictionaryServices-7.1
pyobjc-framework-DiscRecording-7.1
pyobjc-framework-DiscRecordingUI-7.1
pyobjc-framework-DiskArbitration-7.1
pyobjc-framework-EventKit-7.1
pyobjc-framework-ExceptionHandling-7.1
pyobjc-framework-ExternalAccessory-7.1
pyobjc-framework-FSEvents-7.1
pyobjc-framework-FinderSync-7.1
pyobjc-framework-GameCenter-7.1
pyobjc-framework-GameController-7.1
pyobjc-framework-GameKit-7.1
pyobjc-framework-GameplayKit-7.1
pyobjc-framework-IMServicePlugIn-7.1
pyobjc-framework-IOSurface-7.1
pyobjc-framework-ImageCaptureCore-7.1
pyobjc-framework-InputMethodKit-7.1
pyobjc-framework-InstallerPlugins-7.1
pyobjc-framework-InstantMessage-7.1
pyobjc-framework-Intents-7.1
pyobjc-framework-LatentSemanticMapping-7.1
pyobjc-framework-LaunchServices-7.1
pyobjc-framework-LocalAuthentication-7.1
pyobjc-framework-MapKit-7.1
pyobjc-framework-MediaAccessibility-7.1
pyobjc-framework-MediaLibrary-7.1
pyobjc-framework-MediaPlayer-7.1
pyobjc-framework-MediaToolbox-7.1
pyobjc-framework-Metal-7.1
pyobjc-framework-MetalKit-7.1
pyobjc-framework-MetalPerformanceShaders-7.1
pyobjc-framework-ModelIO-7.1
pyobjc-framework-MultipeerConnectivity-7.1
pyobjc-framework-NaturalLanguage-7.1
pyobjc-framework-NetFS-7.1
pyobjc-framework-Network-7.1
pyobjc-framework-NetworkExtension-7.1
pyobjc-framework-NotificationCenter-7.1
pyobjc-framework-OSAKit-7.1
pyobjc-framework-OpenDirectory-7.1
pyobjc-framework-Photos-7.1
pyobjc-framework-PhotosUI-7.1
pyobjc-framework-PreferencePanes-7.1
pyobjc-framework-Quartz-7.1
pyobjc-framework-SafariServices-7.1
pyobjc-framework-SceneKit-7.1
pyobjc-framework-ScreenSaver-7.1
pyobjc-framework-ScriptingBridge-7.1
pyobjc-framework-SearchKit-7.1
pyobjc-framework-Security-7.1
pyobjc-framework-SecurityFoundation-7.1
pyobjc-framework-SecurityInterface-7.1
pyobjc-framework-ServiceManagement-7.1
pyobjc-framework-Social-7.1
pyobjc-framework-SpriteKit-7.1
pyobjc-framework-StoreKit-7.1
pyobjc-framework-SyncServices-7.1
pyobjc-framework-SystemConfiguration-7.1
pyobjc-framework-UserNotifications-7.1
pyobjc-framework-VideoSubscriberAccount-7.1
pyobjc-framework-VideoToolbox-7.1
pyobjc-framework-Vision-7.1
pyobjc-framework-WebKit-7.1
pyobjc-framework-iTunesLibrary-7.1
pyobjc-framework-libdispatch-7.1

current code incompatible with urllib3 v2

Good Morning,

First i'd like to thank you for this project, it's been very useful to authenticate our users by certificates on multiple internal tools we developped.

Since the release of URLLIB3 2.x the code error as follow :

line 8, in <module> from .simple_adapter import SimpleKeychainAdapter File "REDACTED/lib/python3.9/site-packages/macsesh/simple_adapter.py", line 8, in <module> from .util import extract_from_urllib3 File "REDACTED/lib/python3.9/site-packages/macsesh/util.py", line 10, in <module> ORIGINAL_HAS_SNI = urllib3_util.HAS_SNI AttributeError: module 'urllib3.util' has no attribute 'HAS_SNI'

For the time being we've put urllib3<2 in our requirements.txt project files to mitigate the issue, probably something that should be specified on the project setup.py while the code is being updated ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.