Works in Linux but not in windows: SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed:

  api, python, ssl, ssl-certificate, windows

I have the following code:

from authentication.api_security 
import get_user_token //simply get a dictionary with the payload
import urllib3 
import json

def foo(IS_REMOTE_SERVER=True):
    
    if IS_REMOTE_SERVER:        
        url_request='https://MY_FAKE_DOMAIN.com/query=so'
    else:        
        url_request='http://localhost:5010/query=so'

    admin_token = get_admin_token() 
    headers = {'Authorization': 'Bearer '+user_token}  
    http = urllib3.PoolManager()
    
    response = http.request('GET',url_request, headers=headers) 
    data = json.loads(response.data.decode('utf-8'))                                
    print (data)

My Problem

When using WINDOWS 10, the code above will only work in localhost but FAIL TO WORK on the certified SSL site

However, if I run this code from Linux (ubuntu) – both IS_REMOTE_SERVER (True/False) will work perfectly.

What is the workaround to have it work on windows?

Full error message:

urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='MY_FAKE_DOMAIN.com', port=443): Max retries exceeded with url: query? (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1076)')))

I have tried: verify=False in the http.request and urllib3.disable_warnings()

Source: Windows Questions

LEAVE A COMMENT