Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pikatasks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
django
pikatasks
Commits
aa02412f
Commit
aa02412f
authored
7 years ago
by
Dennis Ahrens
Browse files
Options
Downloads
Patches
Plain Diff
Breaking changes in pika master branch again.
Adjusts the SSLOptions API.
parent
838852a7
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
pikatasks/settings.py
+1
-1
1 addition, 1 deletion
pikatasks/settings.py
pikatasks/utils.py
+13
-3
13 additions, 3 deletions
pikatasks/utils.py
with
14 additions
and
4 deletions
pikatasks/settings.py
+
1
−
1
View file @
aa02412f
...
@@ -31,7 +31,7 @@ SSL_CONF = {
...
@@ -31,7 +31,7 @@ SSL_CONF = {
# NOTE: The following values are not meant to be changed through settings
# NOTE: The following values are not meant to be changed through settings
# because this would be a mess in deployment!
# because this would be a mess in deployment!
"
ssl_version
"
:
ssl
.
PROTOCOL_TLSv1_2
,
"
ssl_version
"
:
ssl
.
PROTOCOL_TLSv1_2
,
"
cert_reqs
"
:
ssl
.
CERT_
NONE
,
"
cert_reqs
"
:
ssl
.
CERT_
REQUIRED
,
}
}
# stuff you might want to change sometimes:
# stuff you might want to change sometimes:
...
...
This diff is collapsed.
Click to expand it.
pikatasks/utils.py
+
13
−
3
View file @
aa02412f
import
json
import
json
import
pika
import
pika
import
logging
import
logging
import
ssl
from
.
import
settings
from
.
import
settings
...
@@ -15,6 +16,15 @@ def deserialize(binary):
...
@@ -15,6 +16,15 @@ def deserialize(binary):
return
json
.
loads
(
binary
.
decode
(
"
utf-8
"
))
return
json
.
loads
(
binary
.
decode
(
"
utf-8
"
))
def
get_ssl_options
(
ssl_settings
):
"""
Create pika.SSLOptions based on pikatasks settings.
"""
context
=
ssl
.
SSLContext
(
ssl_settings
.
get
(
'
ssl_version
'
))
context
.
verify_mode
=
(
ssl_settings
.
get
(
'
cert_reqs
'
))
context
.
load_verify_locations
(
ssl_settings
.
get
(
'
ca_certs
'
))
context
.
load_cert_chain
(
ssl_settings
.
get
(
'
certfile
'
),
ssl_settings
.
get
(
'
keyfile
'
))
return
pika
.
SSLOptions
(
context
)
def
get_pika_connection_parameters
():
def
get_pika_connection_parameters
():
return
pika
.
ConnectionParameters
(
return
pika
.
ConnectionParameters
(
host
=
settings
.
BROKER_HOST
,
host
=
settings
.
BROKER_HOST
,
...
@@ -24,9 +34,9 @@ def get_pika_connection_parameters():
...
@@ -24,9 +34,9 @@ def get_pika_connection_parameters():
username
=
settings
.
USERNAME
,
username
=
settings
.
USERNAME
,
password
=
settings
.
PASSWORD
password
=
settings
.
PASSWORD
),
),
blocked_connection_timeout
=
settings
.
BLOCKED_CONNECTION_TIMEOUT
.
total_seconds
(),
# TODO: causes a warning when closing connections
# TODO: causes a warning when closing connections
ssl
=
settings
.
SSL_ENABLED
,
blocked_connection_timeout
=
settings
.
BLOCKED_CONNECTION_TIMEOUT
.
total_seconds
()
,
ssl_options
=
settings
.
SSL_CONF
,
ssl_options
=
get_ssl_options
(
settings
.
SSL_CONF
)
if
settings
.
SSL_ENABLED
else
None
,
)
)
...
...
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