Skip to content

SSL verification failure after packaging as .exe with PyInstaller #954

Open
@WoutervanZeijl

Description

@WoutervanZeijl

I'm using authentication method 1 to upload data to a SharePoint List with client id and client secret. This works fine, but when I package the code as .exe with pyinstaller, then i get an SSL certificate failure. I have tried to disable SSL certificate validation, explicitly load cacert.pem in local folder and adding this as parameter in pyinstaller and adding office365 to the spec file, but to no avail. My code snip:

with open('config.json', 'r') as file:
    config = json.load(file)        
client_id = config['client_id']
client_secret = config['client_secret']
site_url = config['site_url']

def add_non_empty(item_properties, key, value):
    if pd.notna(value) and value != '':
        item_properties[key] = value

ctx = ClientContext(site_url).with_client_credentials(client_id, client_secret)
metadata = pd.read_excel('3_processed_output/metadata.xlsx')
list_title = '08_assessments'
list_obj = ctx.web.lists.get_by_title(list_title)
for index, row in metadata.iterrows():
        item_properties = {}
        add_non_empty(item_properties, 'Localtaxauthority', 'AMSTERDAMMMM')
        new_item = list_obj.add_item(item_properties)
        ctx.execute_query()

The error once ran as .exe:

Traceback (most recent call last):
  File "urllib3\connectionpool.py", line 464, in _make_request
  File "urllib3\connectionpool.py", line 1093, in _validate_conn
  File "urllib3\connection.py", line 741, in connect
  File "urllib3\connection.py", line 920, in _ssl_wrap_socket_and_match_hostname
  File "urllib3\util\ssl_.py", line 460, in ssl_wrap_socket
  File "urllib3\util\ssl_.py", line 504, in _ssl_wrap_socket_impl
  File "ssl.py", line 455, in wrap_socket
  File "ssl.py", line 1041, in _create
  File "ssl.py", line 1319, in do_handshake
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1000)

All tips would be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions