Problems arise
Minio’s server always uses HTTP for access, but recently, due to business requirements, all requests have been replaced with HTTPS requests. After changing to HTTPS, this error will be reported when uploading the file: urlib3. Exceptions. Maxretryerror: httpsconnectionpool (host = ‘10.10.30.241’, port = 9000): Max retries exceeded with URL:/Facebook?Location = (caused by sslerror (sslcertverificationerror (1, ‘[SSL: Certificate_ VERIFY_ FAILED] certificate verify failed: self signed certificate (_ ssl.c:1124)’)))
Solution 1
Because I saw that the error was reported by urlib, I directly searched the urlib source code and directly modified the urlib 3 source code to solve the problem.
the modified file is: connectionpool.py
modify line 775 of connectionpool.py file:
self.cert_reqs = 'CERT_NONE'
Solution 2
The first method is solved, but it is extremely inconvenient
because you need to modify the source code every time you need to change the deployment script or reinstall it
then I went through the Minio source code and found the problem
the urliib in Minio did not turn off SSL verification. I wanted to change it here, but I thought of changing the source code here. I looked carefully and found the next parameter: http_ client
We only need to customize this parameter when creating Minio objects
minioClient = Minio(
'1.1.1.1:9000',
access_key='mxxxxxxx',
secret_key='mxxxxxxx',
http_client=urllib3.PoolManager(
timeout=urllib3.util.Timeout(connect=10, read=10),
maxsize=10,
cert_reqs='CERT_NONE',
ca_certs= os.environ.get('SSL_CERT_FILE') or certifi.where(),
retries=urllib3.Retry(
total=5,
backoff_factor=0.2,
status_forcelist=[500, 502, 503, 504]
)
)
# secure=False
)
So far, the problem is solved
Attach Minio file to upload all codes
import logging
from minio import Minio
from minio.error import S3Error
import urllib3
import certifi
import os
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
logging.basicConfig(
level=logging.INFO,
filename='../mysqlbackup_up.log',
filemode='a',
format='%(asctime)s %(name)s %(levelname)s--%(message)s'
)
def upload_file(file_name, file_path):
minioClient = Minio(
'1.1.3.1:9000',
access_key='mxxxxx',
secret_key='mxxxxxx',
http_client=urllib3.PoolManager(
timeout=urllib3.util.Timeout(connect=10, read=10),
maxsize=10,
cert_reqs='CERT_NONE',
ca_certs= os.environ.get('SSL_CERT_FILE') or certifi.where(),
retries=urllib3.Retry(
total=5,
backoff_factor=0.2,
status_forcelist=[500, 502, 503, 504]
)
)
# secure=False
)
check_bucket = minioClient.bucket_exists("test")
if not check_bucket:
minioClient.make_bucket("test")
try:
logging.info("start upload file")
minioClient.fput_object(bucket_name="test", object_name=file_name, file_path=file_path)
logging.info("file {0} is successfully uploaded".format(file_name))
print('success')
except FileNotFoundError as err:
print(err)
logging.error('upload_failed: ' + str(err))
except S3Error as err:
print(err)
logging.error("upload_failed:", err)
Read More:
- python minio client Error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certific
- Python 3 urllib has no URLEncode attribute
- python3 ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833) Error
- Python error: urllib.error.HTTPError : http Error 404: not found
- _ssl.c:510: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
- [Solved] urllib.error.URLError: <urlopen error [SSL: WRONG_VERSION_NUMBER] wrong version number
- Python: How to Delete Empty Files or Folders in the Directory
- [Solved] Linux OS python Script Error: smtplib has no attribute SMTP_SSL
- urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=‘localhost‘, port=8097): Max retries excee
- Python traverses all files under the specified path and retrieves them according to the time interval
- [zipfile] Python packages files as zip packages & decompresses them
- [Solved] raise ContentTooShortError(urllib.error.ContentTooShortError: <urlopen error retrieval incomplete:
- How to Solve Python Pandas Read or Import Files Error
- Python: SVN deletes files on local and remote repositories
- Python recursively traverses all files in the directory to find the specified file
- [Solved]AttributeError: module ‘urllib’ has no attribute ‘quote’
- There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590)-skipping
- Python parses XML files (parses, updates, writes)
- urllib.error.HTTPError: HTTP Error 403: Forbidden [How to Solve]