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

Document how to skip SSL checks #45

Open
Gallaecio opened this issue Aug 3, 2023 · 0 comments
Open

Document how to skip SSL checks #45

Gallaecio opened this issue Aug 3, 2023 · 0 comments

Comments

@Gallaecio
Copy link
Contributor

While I don’t think #5 is the way to go, documenting how to skip SSL checks may be useful for people for whom getting things working is, at a given time, more important that any security concerns related to SSL.

Something like this should work with the current API, and we could simplify it and cover it in the docs:

import asyncio
import json
from base64 import b64decode

from aiohttp import TCPConnector
from zyte_api.aio.client import AsyncClient, create_session


async def main():
    client = AsyncClient()
    async with create_session(connector=TCPConnector(ssl=False)) as session:
        api_response = await client.request_raw(
            {
                "url": "https://toscrape.com",
                "httpResponseBody": True,
                "httpRequestMethod": "POST",
                "httpRequestBody": "Zm9v",
            },
            session=session,
        )
    http_response_body: bytes = b64decode(api_response["httpResponseBody"])
    body_text: str = http_response_body.decode()
    print(body_text)


asyncio.run(main())

Alternatively, we could consider making it easy to disable SSL checking with a boolean API parameter. No strong opinion either way from me.

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

1 participant