Forum Discussion

chelusco's avatar
chelusco
Icon for Nimbostratus rankNimbostratus
Oct 16, 2024

Uploading SKCS 12 File to F5 Device

I have been stuck on trying to upload an SKCS 12 file to an F5 device. A regular cert works and other files have worked as well but I constantly get an issue "Chunk byte count 7611 in Content-Range header different from received buffer length 11616" despite me having the correct Content-Range calculation. I am currently on python and am posting to 

/mgmt/shared/file-transfer/uploads/{file_name}

I would appreciate the help greatly, thank you

  • Have you tried to use Content-Range: bytes 0-11615/total_file_size in your python script ?      Is there any encoding happening before the upload?  If so double check the encoded length matches what your using in the headers

    • chelusco's avatar
      chelusco
      Icon for Nimbostratus rankNimbostratus

      chunk_size = 512 * 1024 # 512 KB chunk size for uploading

      def upload_file(file_data, file_name):

      total_size = len(file_data)

      url = f'https://{f5_ip}/mgmt/shared/file-transfer/uploads/{file_name}'

      start = 0

      response = None

      while start < total_size:

      end = min(start + chunk_size, total_size)

      file_slice = file_data[start:end]

      content_range = f"{start}-{end - 1}/{total_size}"

      print("Content Range: ", content_range)

      upload_headers['Content-Range'] = content_range

      response = requests.post(url, headers=upload_headers, data=file_slice, verify=False)

      if response.status_code != 200:

      print(f"Error during upload: {response.text}")

      break

      start = end

      print("Response: ", response.text)

      this is currently what I have been using, should I change it? I wanted it to be able to upload any type of file

      • chelusco's avatar
        chelusco
        Icon for Nimbostratus rankNimbostratus

        Also, once uploaded, how would I upload the PKCS 12 file to the devices cert list?