Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
WoutervanZeijl opened this issue Apr 10, 2025 · 0 comments
Open
Labels

Comments

@WoutervanZeijl
Copy link

WoutervanZeijl commented Apr 10, 2025

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.

@vgrem vgrem added the question label Apr 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants