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

[Feedback] Supporting AIA fetching #43

Closed
liquidz00 opened this issue Jun 25, 2024 · 1 comment
Closed

[Feedback] Supporting AIA fetching #43

liquidz00 opened this issue Jun 25, 2024 · 1 comment
Labels
feedback Potential improvements or changes

Comments

@liquidz00
Copy link
Contributor

Current

Presently, the requests library is being leveraged for API call functionality. However, in managed environments, this can cause a potential issue with SSL verification as Python does not natively support AIA fetching.

Zscaler is a relatively common offender of this. In my environment, we added the Jamf Pro & Classic API to the global SSL bypass in the Zscaler admin console, and SSL verification still failed.

Proposed

The asyncio library supports asynchronous shell command execution with asyncio.create_subprocess_shell(). This can be leveraged to use /usr/bin/curl which does support AIA fetching. Running the command in the linked comment can verify that curl does not mention or reference OpenSSL.

Below is a basic example of how to accomplish this. The headers variable can be formatted/validated properly with use with the SDK, the below use is just a sample.

import asyncio

headers = {"Accept": "application/json", "Authorization": f"Bearer {jamf_token}"}

headers_string = " ".join(
        [f'-H "{key}: {value}"' for key, value in headers.items()]
)

command = f"curl -s -X GET {headers_string} {url}"

try:
    process = await asyncio.create_subprocess_shell(
        command, stdout=subprocess.PIPE, stderr=subprocess.PIPE
    )
    stdout, stderr = await process.communicate()
except asyncio.TimeoutError as e:
    logging.error(f"Request to API timed out: {e}")
    raise

System Information

macOS 14.5, Python 3.10, 3.11, 3.12, Jamf Pro version 11.6.1.

@liquidz00 liquidz00 added the feedback Potential improvements or changes label Jun 25, 2024
@liquidz00
Copy link
Contributor Author

liquidz00 commented Jun 25, 2024

Closing in favor of the ca_cert_bundle in the client configuration. Apologies!

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

No branches or pull requests

1 participant