Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Base Worker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Workers
Base Worker
Commits
66f50605
Commit
66f50605
authored
4 years ago
by
Eva Bardou
Committed by
Bastien Abadie
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Support weak SSL DH key when downloading images
parent
cd30de66
No related branches found
No related tags found
1 merge request
!86
Support weak SSL DH key when downloading images
Pipeline
#78425
passed
4 years ago
Stage: release
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arkindex_worker/image.py
+18
-1
18 additions, 1 deletion
arkindex_worker/image.py
with
18 additions
and
1 deletion
arkindex_worker/image.py
+
18
−
1
View file @
66f50605
...
...
@@ -48,10 +48,27 @@ def download_image(url):
Download an image and open it with Pillow
"""
assert
url
.
startswith
(
"
http
"
),
"
Image URL must be HTTP(S)
"
# Download the image
# Cannot use stream=True as urllib's responses do not support the seek(int) method,
# which is explicitly required by Image.open on file-like objects
resp
=
requests
.
get
(
url
,
timeout
=
DOWNLOAD_TIMEOUT
)
try
:
resp
=
requests
.
get
(
url
,
timeout
=
DOWNLOAD_TIMEOUT
)
except
requests
.
exceptions
.
SSLError
:
logger
.
warning
(
"
An SSLError occurred during image download, retrying with a weaker and unsafe SSL configuration
"
)
# Saving current ciphers
previous_ciphers
=
requests
.
packages
.
urllib3
.
util
.
ssl_
.
DEFAULT_CIPHERS
# Downgrading ciphers to download the image
requests
.
packages
.
urllib3
.
util
.
ssl_
.
DEFAULT_CIPHERS
=
"
ALL:@SECLEVEL=1
"
resp
=
requests
.
get
(
url
,
timeout
=
DOWNLOAD_TIMEOUT
)
# Restoring previous ciphers
requests
.
packages
.
urllib3
.
util
.
ssl_
.
DEFAULT_CIPHERS
=
previous_ciphers
resp
.
raise_for_status
()
# Preprocess the image and prepare it for classification
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment