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

verify_certs option not applied in upload_document #27

Open
cso-sekkop opened this issue Feb 25, 2025 · 2 comments
Open

verify_certs option not applied in upload_document #27

cso-sekkop opened this issue Feb 25, 2025 · 2 comments

Comments

@cso-sekkop
Copy link

As says the title, when setting verify_certs to False in the initialisation, upload_document() still verify SSL Certs.

        with open(filepath, 'rb') as fhandler:
            response = requests.post(
                url=self._set_method('Document'),
                headers={
                    'Session-Token': self.session.headers['Session-Token'],
                    'App-Token': self.session.headers['App-Token']
                },
                files={
                    'uploadManifest': (
                        None,
                        _UPLOAD_MANIFEST.format(name=name, filename=os.path.basename(filepath)),
                        'application/json'
                    ),
                    'filename[0]': (filepath, fhandler)
                }
            )

should be:

        with open(filepath, 'rb') as fhandler:
            response = requests.post(
                url=self._set_method('Document'),
                headers={
                    'Session-Token': self.session.headers['Session-Token'],
                    'App-Token': self.session.headers['App-Token']
                },
                files={
                    'uploadManifest': (
                        None,
                        _UPLOAD_MANIFEST.format(name=name, filename=os.path.basename(filepath)),
                        'application/json'
                    ),
                    'filename[0]': (filepath, fhandler)
                },
                verify=self.session.verify
            )
@fmenabe
Copy link
Member

fmenabe commented Feb 25, 2025

Well in fact, the session should be used when making the post instead of using requests directly (response = self.session.post). I don't remember if there was a reason for that (if using the session, headers should not have to be redefined also).

Anyway, will try to find some time to correct that.

@cso-sekkop
Copy link
Author

cso-sekkop commented Mar 1, 2025

I made some test to patch it. When I used self.session instead of requests, the "Content-Type" header and the body was acting weird.
The Content-Type was stuck in "application/json" even with "file=..." used.
Forcing "Content-Type":"formdata" was not working either, their was no "bondary=" present in the request.

My theory is that the content-type of the sessions is manually set somewhere and it mess with requests function.
So using "requests" seems to be the easiest fix.

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

2 participants