Search code examples
pythonhttpsjson-rpcurllib3

Python HTTPS Post: can not find existing url


I am currently working on a project where i have to send json object to an embedded pc, which implements Json RPC. The device is in my LAN, has an ip address and is reachable.

Like two weeks ago my code worked, but as I sat down today to go on it didn't work anymore.

I working with Visual Studio 2017. So far I tried Python 3.4 (64 bit), Python 3.6 (64 and 32bit)

Here is what I tried:

import json
import urllib3
import sys
import base64
import os
import io
import base64
import hashlib
from base64 import b64encode

role = "admin"
passwd = "*******"
service_url = "https://192.168.0.65/base_service/"
http = urllib3.PoolManager( assert_hostname=False, ca_certs="cert/myCertificate.crt" )
passwd_b64 = str( b64encode( bytes( passwd, "utf8" ) ), "utf8" )
rpc_obj = {"jsonrpc": "2.0","id":1,"method":"get_auth_token","params":{"user": "admin", "pwd": passwd_b64}}

at = http.urlopen( "POST", service_url, body=json.dumps( rpc_obj ) )

This should generate an token used for other functions. but at the last line I get this error:

urllib3.exceptions.MaxRetryError
    Nachricht = HTTPSConnectionPool(host='192.168.0.65', port=443): Max retries exceeded with url: /base_service/ (Caused by SSLError(FileNotFoundError(2, 'No such file or directory'),))
    Stapelüberwachung:
C:\Program Files (x86)\Entwicklung\Python\lib\site-packages\urllib3\util\retry.py:388 in "Retry.increment"
C:\Program Files (x86)\Entwicklung\Python\lib\site-packages\urllib3\connectionpool.py:639 in "HTTPConnectionPool.urlopen"
C:\Program Files (x86)\Entwicklung\Python\lib\site-packages\urllib3\connectionpool.py:668 in "HTTPConnectionPool.urlopen"
C:\Program Files (x86)\Entwicklung\Python\lib\site-packages\urllib3\connectionpool.py:668 in "HTTPConnectionPool.urlopen"
C:\Program Files (x86)\Entwicklung\Python\lib\site-packages\urllib3\connectionpool.py:668 in "HTTPConnectionPool.urlopen"
C:\Program Files (x86)\Entwicklung\Python\lib\site-packages\urllib3\poolmanager.py:321 in "PoolManager.urlopen"
C:\Users\UserXY\source\repos\containerController\containerController.py:20 in "<module>"

I have no idea why I get this error. I also have a java programm, which does the same, but works perfectly. Sadly the documentation of the device only has some python examples and I am not able to implement all functions in java.

Does anyone have an idea or hint?


Solution

  • Look at this part of the error: (Caused by SSLError(FileNotFoundError(2, 'No such file or directory'),))

    I think it cannot find the certificate file.