tus/tus-py-client

Turn off the certificate check

AkbarAlam opened this issue · 9 comments

How can I turn off certificate check in Tus-Python client ? I have tried the following as suggested before,

import ssl
ssl._create_default_https_context = ssl._create_unverified_context

But this does not work still getting the following error

Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),))

On the Other Hand what would be the equivalent code for this nodejs client?

var file_to_upload = "./data_folder/text_csv.csv"

var file = fs.createReadStream(file_to_upload)
var size = fs.statSync(file_to_upload).size

const TOKEN = "<TOKEN>"
const DIR = "<DIR_ID>"

let upload = new tus.Upload(file, {
    endpoint: 'URL',
    retryDelays: [0, 1000, 3000, 5000],
    uploadSize: size,
    metadata: {
        filename: "blahblah.txt",
        directoryId: DIR,
        authorization: TOKEN
    },
    onError: function(error) {
      console.log(error)
    },
    onProgress: function(bytesUploaded, bytesTotal) {
      console.log(bytesUploaded + "\t", bytesTotal)
    },
    onSuccess: function() {
      console.log("done")
    }
  })
  
upload.start()

with the given Node code the upload works if i set

const process = require('process')
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0

Do you have an idea what is up with your certificate and why Python is rejecting it? Is it self-signed? Maybe it's possible for you to get a valid certificate.

I am not aware about that :( , However the Node code works :

What error do you get when you visit the tus endpoint in your browser?

well, it is giving me 404, well I have to insert the credentials, which needs to be done the way NodeJS example works. that code works, But I am not sure How can I do this with the Python client

What credentials are you referring to? I cannot find them in your Node.js example

@Acconut the user credentials where i have to upload the file

Sorry, I don't understand what credentials you mean.
Which version of Python are you using? Would you mind sharing what your endpoint URL is?

Closing this issue due to inactivity. Feel free to leave a comment if you want to continue the discussion :)