N4S4 / synology-api

A Python wrapper around Synology API
MIT License
360 stars 137 forks source link

core_certificate upload_cert() not working #150

Closed dkmonaghan closed 5 months ago

dkmonaghan commented 5 months ago

Describe the bug Calls to the function upload_cert() in core_certificate.py are not functioning correctly. The Synology API returns {'error': {'code': 119}, 'success': False}.

To Reproduce

#!/usr/bin/python3
from synology_api import core_certificate
syn = core_certificate.Certificate('xxxx', '5001', 'xxxx', 'xxxx', True, False, 7, True)
syn.upload_cert(serv_key="key.pem", ser_cert="cert.crt", ca_cert="ca.crt", set_as_default=True)

Expected behavior The new certificate should be uploaded.

Additional context Had this code running for well over a year on a cron job with Let's Encrypt to update my DSM cert, but now it's stopped working. Other functions within core_certificate.py work fine, e.g., list_cert().

The Synology API returns a vague 'error 119' with no further context.

synology-api version: Latest 0.7 DSM version: 7.2-64570

N4S4 commented 5 months ago

Its the same issue that i am having uploading files, i will try to look into it, not sure if is due to the standardization of the login process. However were u able to test with previous version if is working? I'm out of home right now, unable to check until day after tomorrow. I would revert back the login standardization if that's the issue

dkmonaghan commented 5 months ago

Yes, can confirm 0.6.3 works ok!

N4S4 commented 5 months ago

Ok not sure what is the issue but ill revert back the login process to the old way . Will do my best to do as soon as possible

linenote-me commented 5 months ago

@N4S4 @dkmonaghan

I have resolved the issue.

Please delete the enable_syno_token parameter from the code at this location https://github.com/N4S4/synology-api/blob/fbb6f91491fab3c0bd83eba3db2089b96ef6921c/synology_api/auth.py#L55

The exact cause has not been identified, but it appears to be related to the login session (_sid). An interesting point is that the enable_syno_token parameter option does not appear in the Synology official documentation. We need to verify where this parameter is used.

DS918+ DSM 7.1.1-42962 Update 2

N4S4 commented 5 months ago

That is great! I suspected what something related to syno_token. Yeah it is not showing in docs but when you sniff request from browser appear if multi data request is made. Thank tou very much for the effort I am not being able to use a vpn so couldn't do any test. I will make a PR and submit the changes with mention!

N4S4 commented 5 months ago

fixed with pr #153